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
- DataViewSetting.cs
- AssemblyEvidenceFactory.cs
- OutputCacheModule.cs
- XmlSchemaComplexContentRestriction.cs
- WebBodyFormatMessageProperty.cs
- OperationContext.cs
- NameScopePropertyAttribute.cs
- TextFormatter.cs
- UpdateRecord.cs
- LoginView.cs
- UpdateCompiler.cs
- AncestorChangedEventArgs.cs
- DefaultObjectMappingItemCollection.cs
- ObjectDataSourceSelectingEventArgs.cs
- PageSettings.cs
- FlowNode.cs
- XmlQueryTypeFactory.cs
- DocumentXPathNavigator.cs
- TripleDES.cs
- HtmlSelect.cs
- HintTextConverter.cs
- SqlTriggerContext.cs
- SQLSingle.cs
- AutoGeneratedFieldProperties.cs
- HtmlElement.cs
- ScrollProperties.cs
- DataGridViewCheckBoxColumn.cs
- QuaternionValueSerializer.cs
- DesignerFrame.cs
- NativeActivityMetadata.cs
- NotifyIcon.cs
- DefaultBindingPropertyAttribute.cs
- WindowsStreamSecurityElement.cs
- dataSvcMapFileLoader.cs
- BaseCAMarshaler.cs
- TypeGeneratedEventArgs.cs
- ButtonBase.cs
- WebPartPersonalization.cs
- XsltConvert.cs
- columnmapkeybuilder.cs
- PolicyUtility.cs
- AppLevelCompilationSectionCache.cs
- AutoGeneratedFieldProperties.cs
- ConnectionPointCookie.cs
- LinkArea.cs
- ControlDesigner.cs
- DataFieldConverter.cs
- Style.cs
- TextClipboardData.cs
- TypeLoadException.cs
- FileLoadException.cs
- Parser.cs
- ProjectionPathSegment.cs
- UInt64Storage.cs
- DetailsView.cs
- XmlParserContext.cs
- TimelineGroup.cs
- versioninfo.cs
- QueryStoreStatusRequest.cs
- CellTreeNodeVisitors.cs
- Int32CAMarshaler.cs
- HttpListenerRequestUriBuilder.cs
- DynamicDiscoSearcher.cs
- GridViewRowEventArgs.cs
- ListItemCollection.cs
- HttpApplicationStateWrapper.cs
- ColumnMapCopier.cs
- LogSwitch.cs
- CommandBindingCollection.cs
- NamespaceEmitter.cs
- NameValuePair.cs
- DataObjectFieldAttribute.cs
- DataListItemCollection.cs
- TextEditorSpelling.cs
- CapabilitiesAssignment.cs
- HttpServerUtilityWrapper.cs
- ExpressionReplacer.cs
- dataobject.cs
- ListDictionaryInternal.cs
- DataGridViewColumnHeaderCell.cs
- PkcsMisc.cs
- xmlfixedPageInfo.cs
- TimelineCollection.cs
- SByte.cs
- Page.cs
- ConstructorArgumentAttribute.cs
- TerminatorSinks.cs
- TagPrefixInfo.cs
- SelectedDatesCollection.cs
- _NegoStream.cs
- TextServicesCompartment.cs
- ViewGenerator.cs
- ParseChildrenAsPropertiesAttribute.cs
- TimeSpanStorage.cs
- WorkerRequest.cs
- WhitespaceSignificantCollectionAttribute.cs
- DefaultTraceListener.cs
- RegexFCD.cs
- BackStopAuthenticationModule.cs
- ComponentDispatcherThread.cs