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
- InfoCardRSACryptoProvider.cs
- ModulesEntry.cs
- WebPartConnectionsCancelEventArgs.cs
- IISUnsafeMethods.cs
- FacetEnabledSchemaElement.cs
- ThemeDirectoryCompiler.cs
- OperationCanceledException.cs
- PolicyLevel.cs
- SHA256.cs
- MetadataException.cs
- CacheMemory.cs
- LayoutEvent.cs
- InternalControlCollection.cs
- TypeSystemProvider.cs
- _ListenerRequestStream.cs
- BufferedGraphics.cs
- ResourceReader.cs
- SqlInternalConnection.cs
- EntityDataSourceQueryBuilder.cs
- Splitter.cs
- ServerIdentity.cs
- Track.cs
- ValueCollectionParameterReader.cs
- PointCollectionConverter.cs
- PointHitTestResult.cs
- HScrollBar.cs
- DeviceContext2.cs
- OlePropertyStructs.cs
- PageEventArgs.cs
- BufferedGraphics.cs
- SerializationStore.cs
- FixedTextPointer.cs
- ToolStripItemEventArgs.cs
- TypeLoadException.cs
- sqlser.cs
- SecureEnvironment.cs
- Attributes.cs
- NonClientArea.cs
- StylusPointPropertyInfo.cs
- SspiHelper.cs
- TemplateControlBuildProvider.cs
- DatasetMethodGenerator.cs
- DesignTimeTemplateParser.cs
- ValueProviderWrapper.cs
- CurrencyManager.cs
- ValidationEventArgs.cs
- Label.cs
- XmlSiteMapProvider.cs
- JumpList.cs
- ObjectMemberMapping.cs
- QueryReaderSettings.cs
- SqlInternalConnection.cs
- XmlCompatibilityReader.cs
- DesigntimeLicenseContext.cs
- WorkflowMessageEventHandler.cs
- MarkupWriter.cs
- DefaultProfileManager.cs
- ReflectionHelper.cs
- EncoderReplacementFallback.cs
- SoundPlayer.cs
- PropertyRef.cs
- GridViewActionList.cs
- ByteAnimation.cs
- DesignUtil.cs
- Authorization.cs
- AvTrace.cs
- PathSegment.cs
- SynthesizerStateChangedEventArgs.cs
- InputBuffer.cs
- LinkedResourceCollection.cs
- PreProcessor.cs
- DocumentScope.cs
- DocumentPageViewAutomationPeer.cs
- SmtpLoginAuthenticationModule.cs
- TiffBitmapEncoder.cs
- UIElement3DAutomationPeer.cs
- WindowPattern.cs
- ToolboxItemFilterAttribute.cs
- EntitySet.cs
- UrlMappingsModule.cs
- SmiSettersStream.cs
- BlobPersonalizationState.cs
- AuthenticationService.cs
- ControlCollection.cs
- DbMetaDataFactory.cs
- DesignerProperties.cs
- AssemblyBuilderData.cs
- SubtreeProcessor.cs
- InputProviderSite.cs
- ReadOnlyNameValueCollection.cs
- ToolboxBitmapAttribute.cs
- ClosableStream.cs
- FontStretches.cs
- SecondaryViewProvider.cs
- DataGridViewCellEventArgs.cs
- UnsafeNativeMethodsMilCoreApi.cs
- DispatchChannelSink.cs
- DataGridItem.cs
- DateTimeFormat.cs
- ConfigurationSchemaErrors.cs