Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- DocumentAutomationPeer.cs
- CommunicationObjectAbortedException.cs
- AttachedPropertyMethodSelector.cs
- XmlMembersMapping.cs
- HtmlButton.cs
- SchemaEntity.cs
- MouseGestureValueSerializer.cs
- DocumentViewerBase.cs
- ApplicationTrust.cs
- altserialization.cs
- SecurityKeyUsage.cs
- GridEntry.cs
- OdbcConnection.cs
- XmlEncodedRawTextWriter.cs
- BaseResourcesBuildProvider.cs
- XslTransform.cs
- AssociationType.cs
- RuntimeIdentifierPropertyAttribute.cs
- WorkflowInstanceRecord.cs
- CodeRemoveEventStatement.cs
- MemberHolder.cs
- Ray3DHitTestResult.cs
- TextServicesCompartmentContext.cs
- AddressHeader.cs
- PropertyPath.cs
- ScrollChrome.cs
- UnsafeNativeMethods.cs
- CodeGroup.cs
- AspNetCacheProfileAttribute.cs
- _DisconnectOverlappedAsyncResult.cs
- RootNamespaceAttribute.cs
- ScrollBar.cs
- DataObject.cs
- XmlNullResolver.cs
- CookieProtection.cs
- BamlRecordReader.cs
- ArcSegment.cs
- InheritanceUI.cs
- XmlChildNodes.cs
- Monitor.cs
- WinEventWrap.cs
- TemplateNameScope.cs
- SqlReferenceCollection.cs
- relpropertyhelper.cs
- Selection.cs
- StringDictionaryEditor.cs
- DoWhileDesigner.xaml.cs
- SubpageParaClient.cs
- BamlTreeMap.cs
- DetailsViewPageEventArgs.cs
- BaseDataListComponentEditor.cs
- PrimitiveList.cs
- EdmRelationshipRoleAttribute.cs
- XmlSchemaValidator.cs
- SubpageParagraph.cs
- MetaModel.cs
- Visual3D.cs
- SqlServices.cs
- RSACryptoServiceProvider.cs
- DataListItemEventArgs.cs
- HtmlInputButton.cs
- FactoryMaker.cs
- HealthMonitoringSectionHelper.cs
- StrokeCollection2.cs
- HtmlInputFile.cs
- TransactionCache.cs
- ToolStripTextBox.cs
- ConfigXmlComment.cs
- MessageHeaderInfoTraceRecord.cs
- BreakRecordTable.cs
- ConfigXmlWhitespace.cs
- GroupStyle.cs
- SearchForVirtualItemEventArgs.cs
- DataService.cs
- Repeater.cs
- CornerRadiusConverter.cs
- CriticalFinalizerObject.cs
- ComponentRenameEvent.cs
- WaitForChangedResult.cs
- StandardOleMarshalObject.cs
- Lasso.cs
- WebBrowserBase.cs
- IDReferencePropertyAttribute.cs
- ExceptionHandlerDesigner.cs
- XmlSchemaAny.cs
- MessagePartSpecification.cs
- GetWinFXPath.cs
- ObjectIDGenerator.cs
- Classification.cs
- SignedInfo.cs
- CustomError.cs
- HealthMonitoringSectionHelper.cs
- ScrollProperties.cs
- BufferModesCollection.cs
- JoinTreeNode.cs
- SearchForVirtualItemEventArgs.cs
- RegistryPermission.cs
- SingleSelectRootGridEntry.cs
- OneToOneMappingSerializer.cs
- TemplateBindingExpressionConverter.cs