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
- PinnedBufferMemoryStream.cs
- PersistenceTypeAttribute.cs
- GPRECTF.cs
- Touch.cs
- Typography.cs
- SoapMessage.cs
- RequestCache.cs
- MemberInfoSerializationHolder.cs
- SocketException.cs
- AsyncCompletedEventArgs.cs
- SqlXmlStorage.cs
- MenuItemStyle.cs
- SafeArrayRankMismatchException.cs
- NodeLabelEditEvent.cs
- EmptyQuery.cs
- MultipleViewPattern.cs
- DrawItemEvent.cs
- ValidationErrorInfo.cs
- DoubleAverageAggregationOperator.cs
- TypedReference.cs
- PropertyPathConverter.cs
- DataGridToolTip.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- SelectionProviderWrapper.cs
- ErrorReporting.cs
- ProcessModule.cs
- DataListItemEventArgs.cs
- ImmutableAssemblyCacheEntry.cs
- CharAnimationBase.cs
- DataGridColumnHeaderAutomationPeer.cs
- PrintDialog.cs
- InputGestureCollection.cs
- CategoryNameCollection.cs
- InvalidPrinterException.cs
- ServiceBusyException.cs
- DataGridRow.cs
- QualificationDataItem.cs
- ViewgenGatekeeper.cs
- ClientRolePrincipal.cs
- LayoutEngine.cs
- GroupBoxDesigner.cs
- SamlNameIdentifierClaimResource.cs
- CookielessHelper.cs
- IApplicationTrustManager.cs
- RequestContextBase.cs
- DBSchemaTable.cs
- ConfigPathUtility.cs
- HelpExampleGenerator.cs
- TemplateInstanceAttribute.cs
- XmlEnumAttribute.cs
- XamlTreeBuilder.cs
- TextDecorationCollectionConverter.cs
- WebContext.cs
- LookupNode.cs
- VariableQuery.cs
- xdrvalidator.cs
- RoleGroupCollection.cs
- Int16KeyFrameCollection.cs
- OperandQuery.cs
- ThreadExceptionDialog.cs
- DateTimePicker.cs
- AuthenticationConfig.cs
- CompilerCollection.cs
- _NestedMultipleAsyncResult.cs
- WmfPlaceableFileHeader.cs
- SerializableTypeCodeDomSerializer.cs
- Tuple.cs
- versioninfo.cs
- RegexCompilationInfo.cs
- DesignerProperties.cs
- PropertyTabChangedEvent.cs
- mactripleDES.cs
- HttpWebResponse.cs
- GeneralTransform3DCollection.cs
- MappingMetadataHelper.cs
- TextEditorContextMenu.cs
- EntityViewGenerator.cs
- ModelService.cs
- PassportAuthenticationEventArgs.cs
- coordinatorscratchpad.cs
- NotifyInputEventArgs.cs
- IntranetCredentialPolicy.cs
- DecoderFallback.cs
- TextElementEditingBehaviorAttribute.cs
- UrlMappingCollection.cs
- SafeNativeMethods.cs
- SingleAnimationUsingKeyFrames.cs
- GeneralTransform3DCollection.cs
- OpenFileDialog.cs
- BuiltInExpr.cs
- HttpWrapper.cs
- DispatcherTimer.cs
- Misc.cs
- Serializer.cs
- DrawingCollection.cs
- TypeConstant.cs
- QueryableDataSourceView.cs
- ListBox.cs
- SchemaReference.cs
- DesignerAutoFormatStyle.cs