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
- ComboBoxItem.cs
- DownloadProgressEventArgs.cs
- MatrixKeyFrameCollection.cs
- PersonalizablePropertyEntry.cs
- UnmanagedHandle.cs
- BidOverLoads.cs
- XmlElementAttributes.cs
- PageThemeParser.cs
- SvcMapFileLoader.cs
- RemoteArgument.cs
- ResourceExpressionBuilder.cs
- CommonRemoteMemoryBlock.cs
- NCryptSafeHandles.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ConvertBinder.cs
- InstalledVoice.cs
- Ref.cs
- EventLogPermissionEntryCollection.cs
- Header.cs
- CodeAccessPermission.cs
- WindowsStatusBar.cs
- UInt16.cs
- ServiceNotStartedException.cs
- PrintController.cs
- ValueExpressions.cs
- CredentialSelector.cs
- HttpException.cs
- EmbossBitmapEffect.cs
- ExpressionNode.cs
- HttpContextWrapper.cs
- LayoutUtils.cs
- LogReserveAndAppendState.cs
- InstanceLockQueryResult.cs
- BaseTemplateCodeDomTreeGenerator.cs
- NavigationProgressEventArgs.cs
- PrinterResolution.cs
- FeatureSupport.cs
- CodePageUtils.cs
- CompilationRelaxations.cs
- FormViewInsertedEventArgs.cs
- HistoryEventArgs.cs
- SecurityManager.cs
- AnnotationObservableCollection.cs
- WebServiceHost.cs
- GlyphRun.cs
- AccessedThroughPropertyAttribute.cs
- NameValueSectionHandler.cs
- ContentElement.cs
- HelpEvent.cs
- NullReferenceException.cs
- FileVersionInfo.cs
- ParseChildrenAsPropertiesAttribute.cs
- WebPartZoneBase.cs
- RawStylusInput.cs
- BaseServiceProvider.cs
- UICuesEvent.cs
- XmlNode.cs
- DataReaderContainer.cs
- ProjectionCamera.cs
- MatrixTransform3D.cs
- Size3DConverter.cs
- SchemaElementLookUpTable.cs
- IDataContractSurrogate.cs
- GcHandle.cs
- SecurityManager.cs
- JsonDeserializer.cs
- SatelliteContractVersionAttribute.cs
- GridErrorDlg.cs
- ImpersonateTokenRef.cs
- PasswordBox.cs
- WpfXamlType.cs
- Utility.cs
- RenderDataDrawingContext.cs
- TraceSwitch.cs
- ProfileProvider.cs
- CompilerScope.cs
- WS2007HttpBinding.cs
- SamlDelegatingWriter.cs
- cookie.cs
- ServiceXNameTypeConverter.cs
- InstanceLockLostException.cs
- EnumValAlphaComparer.cs
- FunctionImportElement.cs
- TextInfo.cs
- ScopedMessagePartSpecification.cs
- StorageMappingItemLoader.cs
- ArrayConverter.cs
- RequiredAttributeAttribute.cs
- xmlglyphRunInfo.cs
- XmlWriterTraceListener.cs
- GC.cs
- PackWebResponse.cs
- ThreadSafeList.cs
- EncryptedXml.cs
- RadialGradientBrush.cs
- LifetimeManager.cs
- UIElementHelper.cs
- LocatorManager.cs
- PrePrepareMethodAttribute.cs
- DesignOnlyAttribute.cs