Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Controls / BooleanToVisibilityConverter.cs / 1 / BooleanToVisibilityConverter.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Windows; using System.Windows.Media; using System.Windows.Data; using System.Globalization; using System.Collections.Generic; using MS.Internal.Controls; namespace System.Windows.Controls { ////// Convert between boolean and visibility /// [Localizability(LocalizationCategory.NeverLocalize)] public sealed class BooleanToVisibilityConverter : IValueConverter { ////// Convert bool or Nullable<bool> to Visibility /// /// bool or Nullable<bool> /// Visibility /// null /// null ///Visible or Collapsed public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { bool bValue = false; if (value is bool) { bValue = (bool)value; } else if (value is Nullable) { Nullable tmp = (Nullable )value; bValue = tmp.HasValue ? tmp.Value : false; } return (bValue) ? Visibility.Visible : Visibility.Collapsed; } /// /// Convert Visibility to boolean /// /// /// /// /// ///public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Visibility) { return (Visibility)value == Visibility.Visible; } else { return false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Windows; using System.Windows.Media; using System.Windows.Data; using System.Globalization; using System.Collections.Generic; using MS.Internal.Controls; namespace System.Windows.Controls { /// /// Convert between boolean and visibility /// [Localizability(LocalizationCategory.NeverLocalize)] public sealed class BooleanToVisibilityConverter : IValueConverter { ////// Convert bool or Nullable<bool> to Visibility /// /// bool or Nullable<bool> /// Visibility /// null /// null ///Visible or Collapsed public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { bool bValue = false; if (value is bool) { bValue = (bool)value; } else if (value is Nullable) { Nullable tmp = (Nullable )value; bValue = tmp.HasValue ? tmp.Value : false; } return (bValue) ? Visibility.Visible : Visibility.Collapsed; } /// /// Convert Visibility to boolean /// /// /// /// /// ///public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Visibility) { return (Visibility)value == Visibility.Visible; } else { return false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ExpressionBindingCollection.cs
- Html32TextWriter.cs
- TypeRestriction.cs
- DelayedRegex.cs
- EpmCustomContentSerializer.cs
- BeginEvent.cs
- TextWriter.cs
- BulletChrome.cs
- SourceFileBuildProvider.cs
- ProfileService.cs
- DataReaderContainer.cs
- SessionEndingCancelEventArgs.cs
- EventPrivateKey.cs
- Grant.cs
- IdentitySection.cs
- SettingsBase.cs
- TextInfo.cs
- FontCacheUtil.cs
- TimeZone.cs
- RegexCompilationInfo.cs
- ClientSession.cs
- DataControlFieldCell.cs
- OdbcFactory.cs
- Activity.cs
- AutomationIdentifierGuids.cs
- SqlFactory.cs
- FixedElement.cs
- SerializableAttribute.cs
- PasswordBoxAutomationPeer.cs
- InvalidCommandTreeException.cs
- ObjectStateFormatter.cs
- FloaterBaseParagraph.cs
- CatalogPartChrome.cs
- DescendantOverDescendantQuery.cs
- Unit.cs
- ModelFactory.cs
- ImagingCache.cs
- BezierSegment.cs
- Brush.cs
- PersonalizablePropertyEntry.cs
- DataObject.cs
- NonParentingControl.cs
- AnimationTimeline.cs
- RegexCaptureCollection.cs
- XmlParserContext.cs
- DataControlField.cs
- XmlUtil.cs
- SafeMarshalContext.cs
- PlaceHolder.cs
- InstanceKeyView.cs
- BamlRecordWriter.cs
- DeviceContexts.cs
- ALinqExpressionVisitor.cs
- HandlerMappingMemo.cs
- listitem.cs
- FindCompletedEventArgs.cs
- _NetRes.cs
- MDIWindowDialog.cs
- Stack.cs
- RoleManagerModule.cs
- MultiPropertyDescriptorGridEntry.cs
- SqlMetaData.cs
- DataTemplateSelector.cs
- DoWorkEventArgs.cs
- ErrorLog.cs
- GenericTextProperties.cs
- MediaTimeline.cs
- ConditionCollection.cs
- OleDbErrorCollection.cs
- SqlInternalConnectionSmi.cs
- DebugView.cs
- RelationHandler.cs
- BulletedListEventArgs.cs
- SchemaNotation.cs
- _BasicClient.cs
- SettingsProperty.cs
- _ConnectionGroup.cs
- TrackingValidationObjectDictionary.cs
- ClientScriptManager.cs
- GcHandle.cs
- IssuanceTokenProviderState.cs
- UndoManager.cs
- ServiceKnownTypeAttribute.cs
- HttpCachePolicy.cs
- PriorityQueue.cs
- embossbitmapeffect.cs
- QueryResults.cs
- XPathConvert.cs
- WebPartDisplayModeCollection.cs
- Color.cs
- CommentAction.cs
- DynamicQueryableWrapper.cs
- DecoderFallback.cs
- XmlToDatasetMap.cs
- RepeaterCommandEventArgs.cs
- TextRunCache.cs
- Container.cs
- WriteFileContext.cs
- MetadataLocation.cs
- ConditionalAttribute.cs