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
- ArgumentOutOfRangeException.cs
- TablePattern.cs
- RangeEnumerable.cs
- GeometryHitTestParameters.cs
- ADMembershipUser.cs
- DbParameterCollectionHelper.cs
- FontDriver.cs
- AtomParser.cs
- SqlProvider.cs
- EngineSiteSapi.cs
- ListViewContainer.cs
- StylusLogic.cs
- OleTxTransaction.cs
- UrlMapping.cs
- Sql8ExpressionRewriter.cs
- FieldToken.cs
- XPathNodeHelper.cs
- DetailsViewDeleteEventArgs.cs
- GeneralTransform3D.cs
- CurrentChangingEventManager.cs
- EpmCustomContentWriterNodeData.cs
- X509CertificateStore.cs
- TemplateLookupAction.cs
- ModifierKeysValueSerializer.cs
- MatrixValueSerializer.cs
- RayHitTestParameters.cs
- NullableLongMinMaxAggregationOperator.cs
- WorkflowInstance.cs
- CommandDesigner.cs
- InvokeHandlers.cs
- GAC.cs
- HtmlInputSubmit.cs
- FunctionMappingTranslator.cs
- ComponentResourceManager.cs
- DesignerActionService.cs
- BitmapEffectGroup.cs
- StrongNameHelpers.cs
- XslNumber.cs
- Propagator.ExtentPlaceholderCreator.cs
- Style.cs
- DecoderExceptionFallback.cs
- BlurBitmapEffect.cs
- HighContrastHelper.cs
- WindowsBrush.cs
- ColumnResizeUndoUnit.cs
- ConfigurationValues.cs
- IdnMapping.cs
- ThemeDirectoryCompiler.cs
- Byte.cs
- DocumentViewerHelper.cs
- ListenerUnsafeNativeMethods.cs
- DirectoryObjectSecurity.cs
- ProjectionCamera.cs
- ObjectReaderCompiler.cs
- ListView.cs
- CompoundFileStorageReference.cs
- GridViewEditEventArgs.cs
- RowVisual.cs
- ProtectedConfiguration.cs
- ProcessInputEventArgs.cs
- CqlLexerHelpers.cs
- AuthenticationException.cs
- SimpleHandlerFactory.cs
- XmlResolver.cs
- DBBindings.cs
- ExpressionDumper.cs
- XmlHierarchicalDataSourceView.cs
- SplitContainer.cs
- VersionValidator.cs
- XmlSchemaInferenceException.cs
- UnaryExpression.cs
- GuidConverter.cs
- ComplexObject.cs
- CodePageUtils.cs
- FormClosedEvent.cs
- ValidationSummaryDesigner.cs
- ClassicBorderDecorator.cs
- SafeProcessHandle.cs
- StrongTypingException.cs
- XPathAncestorQuery.cs
- AtlasWeb.Designer.cs
- TypeHelpers.cs
- OutputBuffer.cs
- IdentityHolder.cs
- DocumentPageView.cs
- RowToFieldTransformer.cs
- UniqueConstraint.cs
- IndicCharClassifier.cs
- QueueProcessor.cs
- AutoResetEvent.cs
- ReadOnlyHierarchicalDataSourceView.cs
- Triangle.cs
- FormViewPagerRow.cs
- ToolStripGrip.cs
- CopyAction.cs
- BinarySerializer.cs
- PresentationAppDomainManager.cs
- DataObjectCopyingEventArgs.cs
- MsmqTransportReceiveParameters.cs
- MimeMapping.cs