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
- MeasureData.cs
- Composition.cs
- HttpHandlersSection.cs
- BuiltInPermissionSets.cs
- SerialReceived.cs
- Section.cs
- infer.cs
- ValidatingPropertiesEventArgs.cs
- XPathBuilder.cs
- WebPartDeleteVerb.cs
- TargetParameterCountException.cs
- PassportAuthenticationEventArgs.cs
- BitArray.cs
- EventDescriptorCollection.cs
- ChtmlPhoneCallAdapter.cs
- ManipulationLogic.cs
- OdbcHandle.cs
- StaticResourceExtension.cs
- PropertyEmitter.cs
- RichTextBoxAutomationPeer.cs
- InheritedPropertyChangedEventArgs.cs
- RelationshipConverter.cs
- DoubleKeyFrameCollection.cs
- WebServiceParameterData.cs
- WebServicesDescriptionAttribute.cs
- ProxyHwnd.cs
- ReferentialConstraint.cs
- TreeNode.cs
- ObjectIDGenerator.cs
- GlyphInfoList.cs
- DataGridViewLinkColumn.cs
- DbProviderConfigurationHandler.cs
- StickyNoteHelper.cs
- DefaultPrintController.cs
- BaseResourcesBuildProvider.cs
- Help.cs
- AnnouncementDispatcherAsyncResult.cs
- ExpressionBuilder.cs
- WebControlAdapter.cs
- WindowsGraphicsWrapper.cs
- EventWaitHandle.cs
- WorkflowMarkupSerializer.cs
- SystemResourceKey.cs
- ServiceAuthorizationElement.cs
- RequestTimeoutManager.cs
- RenderDataDrawingContext.cs
- XappLauncher.cs
- TransportConfigurationTypeElement.cs
- DocumentXmlWriter.cs
- ProgressChangedEventArgs.cs
- HeaderPanel.cs
- XmlSignificantWhitespace.cs
- Vars.cs
- LoadedOrUnloadedOperation.cs
- UnicodeEncoding.cs
- AppDomainCompilerProxy.cs
- IncomingWebRequestContext.cs
- MaterialGroup.cs
- SerializableAttribute.cs
- ComponentResourceKey.cs
- AxisAngleRotation3D.cs
- LocatorBase.cs
- ContextProperty.cs
- SystemIPv4InterfaceProperties.cs
- EqualityArray.cs
- EntityDataSourceEntityTypeFilterItem.cs
- HMACRIPEMD160.cs
- ForwardPositionQuery.cs
- ReadOnlyCollectionBuilder.cs
- XmlResolver.cs
- IfAction.cs
- VirtualizedItemPattern.cs
- XmlDownloadManager.cs
- WebColorConverter.cs
- _ChunkParse.cs
- MarginsConverter.cs
- FileUtil.cs
- EdmToObjectNamespaceMap.cs
- ConstructorExpr.cs
- SecurityPermission.cs
- FocusChangedEventArgs.cs
- CompilationSection.cs
- WebPartConnectionsConfigureVerb.cs
- HttpRuntime.cs
- Stacktrace.cs
- TraceContextEventArgs.cs
- ImmComposition.cs
- XmlSerializerNamespaces.cs
- PathData.cs
- MethodBuilder.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- DataChangedEventManager.cs
- RoleService.cs
- ForceCopyBuildProvider.cs
- ProgressiveCrcCalculatingStream.cs
- SizeF.cs
- AccessorTable.cs
- AdapterUtil.cs
- CacheDependency.cs
- EncryptedPackage.cs