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
- XmlSchemas.cs
- CheckPair.cs
- _UncName.cs
- SerializationUtility.cs
- BitmapEffectInput.cs
- LocalizabilityAttribute.cs
- RuntimeEnvironment.cs
- ZipIOExtraFieldZip64Element.cs
- DocumentSequence.cs
- DrawListViewColumnHeaderEventArgs.cs
- DotExpr.cs
- TreeNodeConverter.cs
- BrowserDefinitionCollection.cs
- ConnectionsZoneAutoFormat.cs
- GlobalProxySelection.cs
- VScrollProperties.cs
- FilterableAttribute.cs
- HttpHandlersSection.cs
- XamlHostingSectionGroup.cs
- Rect3D.cs
- RoutedCommand.cs
- FactoryId.cs
- SiteOfOriginContainer.cs
- RtfNavigator.cs
- ReadOnlyHierarchicalDataSourceView.cs
- TextLine.cs
- NavigationPropertyEmitter.cs
- XmlSchemaException.cs
- DescendantBaseQuery.cs
- WizardSideBarListControlItem.cs
- TextEvent.cs
- BitmapFrameEncode.cs
- ErrorProvider.cs
- DSACryptoServiceProvider.cs
- infer.cs
- PointConverter.cs
- LazyInitializer.cs
- PresentationAppDomainManager.cs
- RadioButtonFlatAdapter.cs
- RouteParameter.cs
- Visitor.cs
- GridItemCollection.cs
- ResourceDictionary.cs
- mactripleDES.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- WorkerRequest.cs
- DataRelation.cs
- glyphs.cs
- TextTreePropertyUndoUnit.cs
- UntrustedRecipientException.cs
- GuidTagList.cs
- LinqDataSourceInsertEventArgs.cs
- DataGridViewColumnCollectionEditor.cs
- Bits.cs
- _BaseOverlappedAsyncResult.cs
- GestureRecognitionResult.cs
- iisPickupDirectory.cs
- HealthMonitoringSectionHelper.cs
- AssemblySettingAttributes.cs
- ApplicationInfo.cs
- FixedLineResult.cs
- SrgsElementFactory.cs
- LaxModeSecurityHeaderElementInferenceEngine.cs
- NamedPipeAppDomainProtocolHandler.cs
- Zone.cs
- AnnotationAdorner.cs
- InfoCardSymmetricAlgorithm.cs
- SecurityDescriptor.cs
- AccessKeyManager.cs
- PresentationTraceSources.cs
- XmlNode.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- SqlTrackingWorkflowInstance.cs
- ReferentialConstraint.cs
- XmlAtomErrorReader.cs
- DataServiceResponse.cs
- MemberCollection.cs
- Interfaces.cs
- PiiTraceSource.cs
- RecognitionResult.cs
- SingleConverter.cs
- BooleanExpr.cs
- IndexOutOfRangeException.cs
- NegatedConstant.cs
- CellTreeNode.cs
- ManipulationDevice.cs
- ToolTipService.cs
- DiscoveryClientProtocol.cs
- DeleteMemberBinder.cs
- FaultHandlingFilter.cs
- PanelStyle.cs
- WebZoneDesigner.cs
- CompiledIdentityConstraint.cs
- DesignSurfaceServiceContainer.cs
- _NetRes.cs
- ClaimTypes.cs
- datacache.cs
- PackUriHelper.cs
- AdvancedBindingEditor.cs
- Camera.cs