Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- RuleSettings.cs
- TextProviderWrapper.cs
- _CommandStream.cs
- MailBnfHelper.cs
- ByteStorage.cs
- ThousandthOfEmRealDoubles.cs
- FlagsAttribute.cs
- Win32PrintDialog.cs
- ShaderEffect.cs
- DataColumnMappingCollection.cs
- ResolveMatchesMessageCD1.cs
- EventProxy.cs
- OutputCacheProfileCollection.cs
- InstalledVoice.cs
- Properties.cs
- TextBoxRenderer.cs
- AssemblyNameProxy.cs
- RSAOAEPKeyExchangeFormatter.cs
- ConfigurationUtility.cs
- ConstructorArgumentAttribute.cs
- CFGGrammar.cs
- WeakReferenceEnumerator.cs
- SerializationFieldInfo.cs
- NetworkAddressChange.cs
- RayHitTestParameters.cs
- MultiAsyncResult.cs
- CompositeScriptReference.cs
- SymbolTable.cs
- CancellationTokenRegistration.cs
- XmlTextEncoder.cs
- EntitySqlQueryCacheKey.cs
- httpapplicationstate.cs
- RootDesignerSerializerAttribute.cs
- StreamAsIStream.cs
- NotificationContext.cs
- Dispatcher.cs
- EntityViewGenerationAttribute.cs
- DataServiceContext.cs
- DeclarativeCatalogPart.cs
- Char.cs
- Cell.cs
- FlowPanelDesigner.cs
- QilGeneratorEnv.cs
- EntityStoreSchemaFilterEntry.cs
- DesignerLoader.cs
- WindowsToolbar.cs
- CommentGlyph.cs
- COM2TypeInfoProcessor.cs
- ColorMatrix.cs
- InvalidWMPVersionException.cs
- TextDecorationCollectionConverter.cs
- DuplicateMessageDetector.cs
- CssTextWriter.cs
- JsonClassDataContract.cs
- DynamicQueryStringParameter.cs
- CodeCompiler.cs
- RSAOAEPKeyExchangeFormatter.cs
- SingleSelectRootGridEntry.cs
- PropertyDescriptors.cs
- xmlglyphRunInfo.cs
- ResXBuildProvider.cs
- NewArray.cs
- ReliabilityContractAttribute.cs
- Error.cs
- UriTemplateDispatchFormatter.cs
- NamespaceMapping.cs
- FilterQuery.cs
- SettingsPropertyWrongTypeException.cs
- LinkUtilities.cs
- TextFormatter.cs
- CSharpCodeProvider.cs
- MouseDevice.cs
- NameTable.cs
- LineServicesRun.cs
- TargetControlTypeAttribute.cs
- TemplatedWizardStep.cs
- _NegoState.cs
- PropertyValueUIItem.cs
- StateManagedCollection.cs
- Operator.cs
- PresentationSource.cs
- ZipIOExtraFieldZip64Element.cs
- SerTrace.cs
- MonthChangedEventArgs.cs
- WebReferencesBuildProvider.cs
- UriSectionData.cs
- ScopeCompiler.cs
- DefaultSerializationProviderAttribute.cs
- WebColorConverter.cs
- unsafenativemethodstextservices.cs
- EntityDataSourceContextDisposingEventArgs.cs
- WebPartsSection.cs
- GlyphManager.cs
- Screen.cs
- ValidationErrorCollection.cs
- PatternMatcher.cs
- HMACSHA512.cs
- ReferentialConstraint.cs
- GridToolTip.cs
- CLSCompliantAttribute.cs