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
- XmlWrappingReader.cs
- DoWhile.cs
- XmlJsonReader.cs
- XMLSchema.cs
- Buffer.cs
- TextServicesLoader.cs
- XmlSchemaSimpleContentRestriction.cs
- StylusDownEventArgs.cs
- PowerModeChangedEventArgs.cs
- TimeStampChecker.cs
- XsltException.cs
- SspiSecurityToken.cs
- ListViewDesigner.cs
- BlockExpression.cs
- ToolStripComboBox.cs
- PrintDialog.cs
- DataGridViewCellParsingEventArgs.cs
- RegisteredHiddenField.cs
- LogLogRecord.cs
- EventSinkHelperWriter.cs
- XamlRtfConverter.cs
- Effect.cs
- CopyCodeAction.cs
- SelectionEditingBehavior.cs
- FreezableDefaultValueFactory.cs
- ConversionValidationRule.cs
- mediaclock.cs
- CompModSwitches.cs
- Label.cs
- GregorianCalendarHelper.cs
- DXD.cs
- EventMappingSettings.cs
- XmlSchemaParticle.cs
- RemotingClientProxy.cs
- jithelpers.cs
- WeakRefEnumerator.cs
- QueryCacheManager.cs
- HelpEvent.cs
- ErrorItem.cs
- WindowsSecurityTokenAuthenticator.cs
- VisualBrush.cs
- PropertyHelper.cs
- MenuItemBinding.cs
- LockCookie.cs
- SerializationTrace.cs
- Debugger.cs
- StyleConverter.cs
- HtmlForm.cs
- HuffmanTree.cs
- HtmlEmptyTagControlBuilder.cs
- ASCIIEncoding.cs
- WebHttpElement.cs
- SystemTcpConnection.cs
- ToolStripScrollButton.cs
- PrimaryKeyTypeConverter.cs
- ControlBindingsCollection.cs
- PrintDialog.cs
- ValidatingPropertiesEventArgs.cs
- _Events.cs
- InputScope.cs
- storepermission.cs
- HttpHandlerActionCollection.cs
- ScrollPatternIdentifiers.cs
- OpCodes.cs
- ComboBoxDesigner.cs
- TextLineBreak.cs
- ProtocolViolationException.cs
- DataGridCell.cs
- PeerResolverElement.cs
- ConfigUtil.cs
- NameObjectCollectionBase.cs
- ViewPort3D.cs
- WmlMobileTextWriter.cs
- TraceLevelHelper.cs
- UIInitializationException.cs
- NativeMethodsOther.cs
- ImageMapEventArgs.cs
- GregorianCalendarHelper.cs
- SoapReflectionImporter.cs
- DesigntimeLicenseContextSerializer.cs
- RangeEnumerable.cs
- HttpCapabilitiesEvaluator.cs
- AnonymousIdentificationSection.cs
- GradientBrush.cs
- ReachDocumentSequenceSerializerAsync.cs
- ObjectDataSourceDisposingEventArgs.cs
- RoleManagerEventArgs.cs
- RelationshipEnd.cs
- HeaderPanel.cs
- ObjectDataSource.cs
- IUnknownConstantAttribute.cs
- SafePEFileHandle.cs
- MaskDesignerDialog.cs
- hwndwrapper.cs
- EntityDataSourceSelectingEventArgs.cs
- LeftCellWrapper.cs
- BindingMAnagerBase.cs
- XhtmlConformanceSection.cs
- TimeoutException.cs
- CqlGenerator.cs