Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / BooleanToVisibilityConverter.cs / 1305600 / 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
- EncryptedReference.cs
- NamedPipeTransportBindingElement.cs
- MediaPlayer.cs
- CommonXSendMessage.cs
- BindingEntityInfo.cs
- NotifyIcon.cs
- RuleValidation.cs
- SqlWriter.cs
- CalendarDay.cs
- InputManager.cs
- ManifestSignedXml.cs
- IndexOutOfRangeException.cs
- BrowserCapabilitiesCompiler.cs
- DocumentViewerBase.cs
- ReadOnlyAttribute.cs
- EntityDataSourceValidationException.cs
- BinaryParser.cs
- ParallelQuery.cs
- RequestStatusBarUpdateEventArgs.cs
- DataSourceHelper.cs
- PropertyDescriptorComparer.cs
- ParallelDesigner.cs
- WCFBuildProvider.cs
- ListView.cs
- ObjectDataSourceFilteringEventArgs.cs
- XmlDesignerDataSourceView.cs
- ProfilePropertySettings.cs
- _ServiceNameStore.cs
- AssertSection.cs
- DesignConnection.cs
- PrintDialogDesigner.cs
- SafeJobHandle.cs
- SimpleRecyclingCache.cs
- base64Transforms.cs
- SharedConnectionWorkflowTransactionService.cs
- ScrollBar.cs
- Block.cs
- GlobalProxySelection.cs
- MethodBody.cs
- SafeIUnknown.cs
- DataSvcMapFile.cs
- UserPreferenceChangedEventArgs.cs
- EncoderExceptionFallback.cs
- ReceiveContent.cs
- TextElementEnumerator.cs
- DecimalStorage.cs
- EntityCodeGenerator.cs
- SpecialTypeDataContract.cs
- DecoderFallback.cs
- MailDefinition.cs
- KeySplineConverter.cs
- FileSecurity.cs
- PersonalizationProviderHelper.cs
- MediaEntryAttribute.cs
- ApplicationHost.cs
- ConnectionPoint.cs
- Set.cs
- ExternalException.cs
- TargetException.cs
- XmlSchemaSimpleTypeList.cs
- MasterPageCodeDomTreeGenerator.cs
- MailWebEventProvider.cs
- ComponentCollection.cs
- Storyboard.cs
- ServerValidateEventArgs.cs
- ConfigurationSectionGroup.cs
- TextBoxBase.cs
- BindingContext.cs
- Stylesheet.cs
- TypeInitializationException.cs
- AnnotationHighlightLayer.cs
- XPathDocumentNavigator.cs
- Repeater.cs
- AnonymousIdentificationModule.cs
- ServiceBuildProvider.cs
- Literal.cs
- SubstitutionList.cs
- RectAnimationClockResource.cs
- LogRecordSequence.cs
- ManagementClass.cs
- Double.cs
- FacetChecker.cs
- IntegerValidator.cs
- UserControl.cs
- DiagnosticsConfigurationHandler.cs
- safemediahandle.cs
- SByte.cs
- FontDriver.cs
- TemplateApplicationHelper.cs
- EndpointDiscoveryElement.cs
- AppDomainUnloadedException.cs
- NamespaceDecl.cs
- EncoderParameters.cs
- PositiveTimeSpanValidator.cs
- SingleKeyFrameCollection.cs
- ListBoxItemWrapperAutomationPeer.cs
- XamlVector3DCollectionSerializer.cs
- RemotingServices.cs
- mediapermission.cs
- HttpGetClientProtocol.cs