Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- TemplateInstanceAttribute.cs
- UidManager.cs
- SerializerWriterEventHandlers.cs
- DataBindingsDialog.cs
- DataFormats.cs
- XmlSchemaSimpleContentRestriction.cs
- TextRunProperties.cs
- ExpressionEditorAttribute.cs
- WebPartChrome.cs
- Attachment.cs
- precedingquery.cs
- ServiceRouteHandler.cs
- CreateUserWizard.cs
- WebPartDisplayModeCancelEventArgs.cs
- SchemaLookupTable.cs
- XmlSchemaObjectTable.cs
- SqlCacheDependencyDatabase.cs
- DesignerTransactionCloseEvent.cs
- AnimationClockResource.cs
- Hashtable.cs
- XmlAtomicValue.cs
- TracePayload.cs
- QueryAccessibilityHelpEvent.cs
- EntryPointNotFoundException.cs
- EdmItemCollection.cs
- XslException.cs
- HttpCacheVary.cs
- StringDictionaryWithComparer.cs
- TemplatedEditableDesignerRegion.cs
- DbConnectionStringBuilder.cs
- UdpTransportSettingsElement.cs
- PolicyLevel.cs
- TerminateWorkflow.cs
- DrawTreeNodeEventArgs.cs
- webproxy.cs
- ConstrainedDataObject.cs
- SynchronizingStream.cs
- ListViewUpdatedEventArgs.cs
- PropertyGroupDescription.cs
- XmlLinkedNode.cs
- AppendHelper.cs
- PagesChangedEventArgs.cs
- DbConnectionPool.cs
- AccessDataSourceView.cs
- MissingMemberException.cs
- PermissionSet.cs
- DataGridViewRowsRemovedEventArgs.cs
- Visual3DCollection.cs
- Column.cs
- XmlDocumentFieldSchema.cs
- SmtpMail.cs
- MimeTypePropertyAttribute.cs
- XmlSchemaSimpleTypeUnion.cs
- VisualTreeUtils.cs
- HyperLinkDataBindingHandler.cs
- PropertyInfo.cs
- Restrictions.cs
- LayoutTable.cs
- FunctionMappingTranslator.cs
- XmlC14NWriter.cs
- UserControlParser.cs
- ObjectKeyFrameCollection.cs
- WindowsTooltip.cs
- ExtensionDataReader.cs
- StreamDocument.cs
- linebase.cs
- DetailsViewInsertedEventArgs.cs
- EncoderExceptionFallback.cs
- GlyphRun.cs
- CompositeFontInfo.cs
- SizeChangedEventArgs.cs
- StylusPointCollection.cs
- DockProviderWrapper.cs
- AsyncCallback.cs
- FaultConverter.cs
- RefExpr.cs
- AssemblyCollection.cs
- XmlSchemas.cs
- WorkflowInspectionServices.cs
- IisHelper.cs
- PixelFormatConverter.cs
- CodeIdentifier.cs
- StatusBarAutomationPeer.cs
- ElementsClipboardData.cs
- SqlCacheDependencyDatabase.cs
- TableItemPatternIdentifiers.cs
- RunInstallerAttribute.cs
- ExpandCollapsePattern.cs
- StylusCaptureWithinProperty.cs
- TableAutomationPeer.cs
- DataKeyCollection.cs
- ListItemConverter.cs
- EntityClassGenerator.cs
- Set.cs
- UInt64.cs
- ClientUrlResolverWrapper.cs
- ProfilePropertyNameValidator.cs
- FigureHelper.cs
- XamlClipboardData.cs
- PeerName.cs