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
- RuntimeResourceSet.cs
- SqlBulkCopyColumnMapping.cs
- Window.cs
- RewritingValidator.cs
- XmlStreamStore.cs
- EncodingTable.cs
- XmlSchemaObjectTable.cs
- DataSourceProvider.cs
- WindowsAuthenticationModule.cs
- Wrapper.cs
- WebPartConnectionsEventArgs.cs
- ListBoxItemWrapperAutomationPeer.cs
- OdbcEnvironment.cs
- PropertyChangedEventManager.cs
- DispatcherEventArgs.cs
- AssemblyAttributes.cs
- XamlValidatingReader.cs
- AdjustableArrowCap.cs
- Parameter.cs
- ErrorFormatterPage.cs
- TransferRequestHandler.cs
- DataGridHelper.cs
- UriTemplateTrieLocation.cs
- RoleManagerSection.cs
- IEnumerable.cs
- TextServicesManager.cs
- Reference.cs
- TableParagraph.cs
- GridViewUpdatedEventArgs.cs
- X509ServiceCertificateAuthenticationElement.cs
- DataServiceRequest.cs
- NativeRightsManagementAPIsStructures.cs
- wmiprovider.cs
- ObjectDataSourceFilteringEventArgs.cs
- ExpandedWrapper.cs
- ValueChangedEventManager.cs
- ErrorActivity.cs
- GeometryHitTestParameters.cs
- SelectedDatesCollection.cs
- PanelStyle.cs
- ChangeBlockUndoRecord.cs
- EnumConverter.cs
- Rotation3DAnimation.cs
- CqlIdentifiers.cs
- Vector3DAnimation.cs
- XmlSchemaCompilationSettings.cs
- CharEntityEncoderFallback.cs
- DependentList.cs
- GestureRecognizer.cs
- ActiveXHost.cs
- ReadOnlyAttribute.cs
- InternalPermissions.cs
- ContactManager.cs
- DragSelectionMessageFilter.cs
- ObjectManager.cs
- DefaultTextStoreTextComposition.cs
- BinaryNode.cs
- ScrollChrome.cs
- XmlUrlResolver.cs
- CompilerScopeManager.cs
- IntegerFacetDescriptionElement.cs
- DependencyPropertyChangedEventArgs.cs
- KeyGestureValueSerializer.cs
- Stopwatch.cs
- SizeChangedEventArgs.cs
- HttpCacheVary.cs
- RawStylusInput.cs
- HttpListener.cs
- BinaryFormatter.cs
- TypedRowHandler.cs
- DataStreams.cs
- ProxyFragment.cs
- ExtentCqlBlock.cs
- ObjectItemAttributeAssemblyLoader.cs
- CheckBoxDesigner.cs
- RuleRefElement.cs
- Trigger.cs
- IntegrationExceptionEventArgs.cs
- EntityDescriptor.cs
- DataTemplate.cs
- TextTreeUndoUnit.cs
- MobileComponentEditorPage.cs
- CodeVariableDeclarationStatement.cs
- SelectiveScrollingGrid.cs
- IteratorDescriptor.cs
- JsonFormatMapping.cs
- CryptoSession.cs
- ScrollProperties.cs
- Rijndael.cs
- VirtualizedItemPattern.cs
- StrongTypingException.cs
- PathGeometry.cs
- TableLayoutColumnStyleCollection.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ComponentEditorPage.cs
- OdbcRowUpdatingEvent.cs
- RtfControls.cs
- OutputCacheSettingsSection.cs
- PropertyGridView.cs
- FilterException.cs