Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UntypedNullExpression.cs
- Command.cs
- RowsCopiedEventArgs.cs
- GestureRecognitionResult.cs
- SvcMapFileLoader.cs
- HwndTarget.cs
- SingleKeyFrameCollection.cs
- DataGridState.cs
- ReadOnlyDataSourceView.cs
- BoundPropertyEntry.cs
- ACE.cs
- ExpressionBuilderContext.cs
- SemanticKeyElement.cs
- AppearanceEditorPart.cs
- Queue.cs
- ObjectConverter.cs
- UIElementAutomationPeer.cs
- StandardTransformFactory.cs
- AccessedThroughPropertyAttribute.cs
- GeometryDrawing.cs
- StreamWriter.cs
- ListBox.cs
- DefaultValueTypeConverter.cs
- FixedSOMLineCollection.cs
- ImageSource.cs
- WsdlImporter.cs
- SqlRewriteScalarSubqueries.cs
- webclient.cs
- StructuredTypeInfo.cs
- SQLInt64.cs
- SqlProcedureAttribute.cs
- MatrixCamera.cs
- PrivilegedConfigurationManager.cs
- LoaderAllocator.cs
- PersonalizationState.cs
- CodeTypeDeclarationCollection.cs
- DocumentViewerConstants.cs
- DataGridPageChangedEventArgs.cs
- AddingNewEventArgs.cs
- NonPrimarySelectionGlyph.cs
- DataGridViewElement.cs
- Int32EqualityComparer.cs
- VisualStyleInformation.cs
- SrgsElementList.cs
- SafeRightsManagementEnvironmentHandle.cs
- WindowPattern.cs
- ListViewTableRow.cs
- Calendar.cs
- SamlSubject.cs
- XslTransform.cs
- MouseButton.cs
- BamlLocalizationDictionary.cs
- GraphicsContainer.cs
- FtpCachePolicyElement.cs
- ImageSource.cs
- PermissionAttributes.cs
- Timeline.cs
- XmlSignatureProperties.cs
- AnonymousIdentificationSection.cs
- SoapRpcServiceAttribute.cs
- CollaborationHelperFunctions.cs
- PasswordDeriveBytes.cs
- DbgUtil.cs
- HitTestParameters.cs
- XmlText.cs
- ProjectionPathSegment.cs
- MenuRenderer.cs
- PolicyException.cs
- hresults.cs
- userdatakeys.cs
- VBIdentifierTrimConverter.cs
- Message.cs
- WorkflowDebuggerSteppingAttribute.cs
- versioninfo.cs
- ObjectDataSourceDisposingEventArgs.cs
- ChtmlTextWriter.cs
- RectangleGeometry.cs
- QueryOperator.cs
- SqlCommandBuilder.cs
- ImageMapEventArgs.cs
- RelationshipWrapper.cs
- Repeater.cs
- TableCell.cs
- HttpValueCollection.cs
- Button.cs
- SettingsPropertyValue.cs
- ExpressionContext.cs
- SegmentTree.cs
- AsyncOperation.cs
- SystemIPInterfaceStatistics.cs
- GetPageNumberCompletedEventArgs.cs
- ClientFormsIdentity.cs
- XmlDigitalSignatureProcessor.cs
- PreloadedPackages.cs
- StorageBasedPackageProperties.cs
- COAUTHINFO.cs
- SystemColors.cs
- SamlAuthenticationStatement.cs
- DeobfuscatingStream.cs
- Matrix3DStack.cs