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
- Type.cs
- ArgumentNullException.cs
- NodeFunctions.cs
- MouseButtonEventArgs.cs
- Margins.cs
- _HeaderInfoTable.cs
- HtmlSelect.cs
- SingleObjectCollection.cs
- BindUriHelper.cs
- XmlQualifiedName.cs
- WindowsAuthenticationEventArgs.cs
- RawStylusInputReport.cs
- TrustExchangeException.cs
- OrthographicCamera.cs
- ErrorItem.cs
- NameTable.cs
- _PooledStream.cs
- Canonicalizers.cs
- XmlNodeList.cs
- DNS.cs
- RegexCompiler.cs
- SymmetricAlgorithm.cs
- RowVisual.cs
- DetailsViewPageEventArgs.cs
- SmtpFailedRecipientException.cs
- SymbolMethod.cs
- PeerToPeerException.cs
- ChangeDirector.cs
- TaiwanLunisolarCalendar.cs
- TextBlockAutomationPeer.cs
- AudioStateChangedEventArgs.cs
- PartialList.cs
- WindowsListViewGroup.cs
- StickyNoteHelper.cs
- SystemIcmpV6Statistics.cs
- PipeException.cs
- AnonymousIdentificationSection.cs
- webclient.cs
- TraceLevelStore.cs
- XmlSchemaParticle.cs
- VisualStateGroup.cs
- CollectionEditVerbManager.cs
- NavigationProperty.cs
- SqlXmlStorage.cs
- WebConfigurationManager.cs
- KnownTypeHelper.cs
- Socket.cs
- WmlImageAdapter.cs
- XmlILTrace.cs
- CodeSubDirectoriesCollection.cs
- XsdBuilder.cs
- InputEventArgs.cs
- Pair.cs
- StringValidator.cs
- XmlSchemaChoice.cs
- IntegerFacetDescriptionElement.cs
- UrlUtility.cs
- XmlDocumentFieldSchema.cs
- TableRowsCollectionEditor.cs
- DataChangedEventManager.cs
- DataGridViewUtilities.cs
- RawStylusActions.cs
- TypographyProperties.cs
- EventsTab.cs
- SubqueryRules.cs
- TraceSection.cs
- ImageListStreamer.cs
- DeobfuscatingStream.cs
- LinqDataSourceStatusEventArgs.cs
- ConfigWriter.cs
- AutomationPeer.cs
- WebHttpBindingCollectionElement.cs
- StrokeCollectionDefaultValueFactory.cs
- WebPartHelpVerb.cs
- CreateUserErrorEventArgs.cs
- ErrorHandler.cs
- AsyncResult.cs
- ReflectPropertyDescriptor.cs
- ConstructorNeedsTagAttribute.cs
- XmlSchemaComplexType.cs
- ToolboxItemFilterAttribute.cs
- PeerChannelListener.cs
- TransactionManager.cs
- METAHEADER.cs
- LockedActivityGlyph.cs
- ImportCatalogPart.cs
- ObjectListDesigner.cs
- StatusBarItem.cs
- UIElement3D.cs
- CatalogZoneBase.cs
- WebPartConnection.cs
- SubtreeProcessor.cs
- AutoResetEvent.cs
- TableLayoutCellPaintEventArgs.cs
- XmlReflectionMember.cs
- TlsSspiNegotiation.cs
- DefaultSettingsSection.cs
- ExpressionEvaluator.cs
- AttachedPropertyMethodSelector.cs
- ExpressionTextBoxAutomationPeer.cs