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
- InternalConfigSettingsFactory.cs
- ListViewDeleteEventArgs.cs
- GregorianCalendar.cs
- HttpErrorTraceRecord.cs
- PropertyGroupDescription.cs
- SafeThemeHandle.cs
- WebServicesDescriptionAttribute.cs
- CollectionBuilder.cs
- OutputCacheSettingsSection.cs
- BufferedReceiveManager.cs
- TextAutomationPeer.cs
- DateTimePickerDesigner.cs
- UnmanagedMemoryStream.cs
- MainMenu.cs
- TextEndOfParagraph.cs
- IndexerNameAttribute.cs
- FlowDocument.cs
- RootDesignerSerializerAttribute.cs
- ThreadPoolTaskScheduler.cs
- SchemaNames.cs
- IISMapPath.cs
- RectConverter.cs
- BrowsableAttribute.cs
- FullTextState.cs
- SortKey.cs
- ListDictionary.cs
- EmptyStringExpandableObjectConverter.cs
- SqlMethodCallConverter.cs
- DropAnimation.xaml.cs
- DataGridColumnCollection.cs
- FlowThrottle.cs
- ASCIIEncoding.cs
- SequenceFullException.cs
- TextServicesPropertyRanges.cs
- Automation.cs
- NumericUpDownAcceleration.cs
- SplitContainer.cs
- HttpPostedFileWrapper.cs
- Soap12ProtocolImporter.cs
- FileStream.cs
- ToolBarOverflowPanel.cs
- WeakEventTable.cs
- DownloadProgressEventArgs.cs
- RoutedUICommand.cs
- RSAOAEPKeyExchangeDeformatter.cs
- DbModificationCommandTree.cs
- MemoryMappedView.cs
- Attributes.cs
- Activity.cs
- AbsoluteQuery.cs
- NullableDoubleMinMaxAggregationOperator.cs
- WorkflowServiceBehavior.cs
- OracleTimeSpan.cs
- ApplicationFileParser.cs
- UnknownBitmapEncoder.cs
- StorageTypeMapping.cs
- CodeFieldReferenceExpression.cs
- Ticks.cs
- Process.cs
- DockProviderWrapper.cs
- ConnectionsZone.cs
- BitmapEffectState.cs
- DbConnectionStringBuilder.cs
- AutomationElementCollection.cs
- DataGridClipboardHelper.cs
- PackageDigitalSignatureManager.cs
- MarkupExtensionParser.cs
- ApplicationInfo.cs
- FileNameEditor.cs
- RtType.cs
- SqlDataSource.cs
- MouseButtonEventArgs.cs
- SqlVisitor.cs
- LineBreak.cs
- BinaryConverter.cs
- SqlInternalConnection.cs
- MarshalByValueComponent.cs
- Adorner.cs
- PaginationProgressEventArgs.cs
- ProcessManager.cs
- Style.cs
- DataContractFormatAttribute.cs
- FontNameEditor.cs
- HostedHttpTransportManager.cs
- LogArchiveSnapshot.cs
- WebControlAdapter.cs
- AbsoluteQuery.cs
- ComponentRenameEvent.cs
- DataControlCommands.cs
- UpWmlPageAdapter.cs
- TabletCollection.cs
- ExtentCqlBlock.cs
- LineGeometry.cs
- ToolboxItemAttribute.cs
- _LocalDataStoreMgr.cs
- UrlMapping.cs
- Crypto.cs
- PenThread.cs
- GorillaCodec.cs
- Utilities.cs