Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- Point.cs
- SelectionItemProviderWrapper.cs
- GridView.cs
- NullRuntimeConfig.cs
- AnchoredBlock.cs
- BrowserDefinitionCollection.cs
- ThicknessKeyFrameCollection.cs
- Scene3D.cs
- ParserStreamGeometryContext.cs
- PenThreadWorker.cs
- Module.cs
- sqlpipe.cs
- InvocationExpression.cs
- AttributeSetAction.cs
- ImageClickEventArgs.cs
- UIElementAutomationPeer.cs
- Renderer.cs
- Visual.cs
- ConfigUtil.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- ActionMismatchAddressingException.cs
- PreservationFileReader.cs
- EmptyStringExpandableObjectConverter.cs
- ExpanderAutomationPeer.cs
- ProfileService.cs
- UTF32Encoding.cs
- COM2PropertyBuilderUITypeEditor.cs
- Style.cs
- SharedPersonalizationStateInfo.cs
- DetailsViewDeletedEventArgs.cs
- DataErrorValidationRule.cs
- CallContext.cs
- RequestUriProcessor.cs
- TabPage.cs
- HandleCollector.cs
- XmlSchemaProviderAttribute.cs
- TextDecorations.cs
- StructuredTypeEmitter.cs
- StatusBarPanelClickEvent.cs
- GeometryGroup.cs
- Type.cs
- DataServiceQueryContinuation.cs
- MetadataItem_Static.cs
- KeyTimeConverter.cs
- FileDialogCustomPlacesCollection.cs
- Internal.cs
- GeometryHitTestParameters.cs
- BuildProviderCollection.cs
- TypedColumnHandler.cs
- PrivilegedConfigurationManager.cs
- RootProfilePropertySettingsCollection.cs
- FrameworkContentElement.cs
- DateTime.cs
- AuthenticationException.cs
- SqlConnectionFactory.cs
- BufferedGraphics.cs
- CodeAttributeDeclarationCollection.cs
- AssemblyCache.cs
- ColorTransform.cs
- XmlSerializationReader.cs
- VirtualizingPanel.cs
- WebPartTransformerCollection.cs
- SvcMapFileSerializer.cs
- XmlTypeAttribute.cs
- SqlBinder.cs
- CssStyleCollection.cs
- HttpWebResponse.cs
- SvcMapFile.cs
- WasHttpHandlersInstallComponent.cs
- _StreamFramer.cs
- HttpApplication.cs
- StringExpressionSet.cs
- CompositeActivityTypeDescriptor.cs
- ConnectionStringsExpressionBuilder.cs
- BinHexEncoding.cs
- TextEndOfSegment.cs
- XmlSchemas.cs
- SplashScreen.cs
- CodeArgumentReferenceExpression.cs
- ProtocolsConfigurationHandler.cs
- DateTimeOffsetStorage.cs
- JavaScriptString.cs
- odbcmetadatacolumnnames.cs
- MachineKeySection.cs
- WpfWebRequestHelper.cs
- OuterGlowBitmapEffect.cs
- EncoderParameter.cs
- PageThemeCodeDomTreeGenerator.cs
- HelpProvider.cs
- NamespaceDisplayAutomationPeer.cs
- ProvideValueServiceProvider.cs
- RIPEMD160Managed.cs
- ProxyWebPartManager.cs
- DbProviderServices.cs
- MsmqAppDomainProtocolHandler.cs
- FixedSOMLineCollection.cs
- SQLBinary.cs
- DesignerDataSchemaClass.cs
- ImageCodecInfoPrivate.cs
- CreateUserErrorEventArgs.cs