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
- BuildProviderUtils.cs
- FixedFlowMap.cs
- DataTableExtensions.cs
- ModuleBuilder.cs
- X509Certificate.cs
- HtmlTitle.cs
- HttpsHostedTransportConfiguration.cs
- FormsAuthenticationUserCollection.cs
- Currency.cs
- SelectionListDesigner.cs
- DuplicateMessageDetector.cs
- DataBindingCollection.cs
- DebugView.cs
- Label.cs
- IdentityNotMappedException.cs
- X500Name.cs
- TemplatedEditableDesignerRegion.cs
- IIS7ConfigurationLoader.cs
- SetterBaseCollection.cs
- RSAOAEPKeyExchangeFormatter.cs
- DeviceSpecificChoice.cs
- smtpconnection.cs
- Stackframe.cs
- ScriptResourceAttribute.cs
- CommonGetThemePartSize.cs
- HttpMethodConstraint.cs
- NullableDoubleAverageAggregationOperator.cs
- DataContractAttribute.cs
- SqlDataSourceCommandEventArgs.cs
- UserControl.cs
- Ref.cs
- InstanceCreationEditor.cs
- TreeNodeCollection.cs
- TransformedBitmap.cs
- Figure.cs
- ImageClickEventArgs.cs
- CacheMemory.cs
- MimeParameter.cs
- PictureBox.cs
- ImportContext.cs
- CodeArrayIndexerExpression.cs
- SupportsEventValidationAttribute.cs
- RectangleGeometry.cs
- QuaternionAnimation.cs
- ProviderCommandInfoUtils.cs
- MultiPropertyDescriptorGridEntry.cs
- HMACMD5.cs
- ZipIOFileItemStream.cs
- XmlElementElementCollection.cs
- Speller.cs
- RankException.cs
- ListViewDataItem.cs
- AssociationTypeEmitter.cs
- CalendarDataBindingHandler.cs
- ComponentCollection.cs
- CompositionAdorner.cs
- TextServicesManager.cs
- PenCursorManager.cs
- MSAAEventDispatcher.cs
- HttpListenerPrefixCollection.cs
- WindowAutomationPeer.cs
- RadioButtonFlatAdapter.cs
- FrameworkTextComposition.cs
- PolicyStatement.cs
- UnsafePeerToPeerMethods.cs
- ClosureBinding.cs
- SafeEventLogWriteHandle.cs
- AttachedPropertyBrowsableAttribute.cs
- PageStatePersister.cs
- Decoder.cs
- ADMembershipProvider.cs
- OptimalBreakSession.cs
- BitmapEffectDrawing.cs
- DateTimeFormatInfoScanner.cs
- VoiceObjectToken.cs
- DeviceOverridableAttribute.cs
- ProfileService.cs
- MenuItem.cs
- TabControlDesigner.cs
- ToolStripOverflowButton.cs
- DataException.cs
- ComboBoxItem.cs
- EndpointPerformanceCounters.cs
- UnescapedXmlDiagnosticData.cs
- ManagementDateTime.cs
- Point4DValueSerializer.cs
- StandardCommandToolStripMenuItem.cs
- Bold.cs
- LinearKeyFrames.cs
- AbstractSvcMapFileLoader.cs
- XhtmlBasicPanelAdapter.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- Unit.cs
- DataGridItemEventArgs.cs
- CodeStatement.cs
- WindowsGraphicsWrapper.cs
- ProfilePropertySettings.cs
- DataReceivedEventArgs.cs
- CircleEase.cs
- cookiecollection.cs