Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HTMLTagNameToTypeMapper.cs
- QueryStringParameter.cs
- HttpRuntimeSection.cs
- BehaviorEditorPart.cs
- RootBrowserWindow.cs
- XmlConverter.cs
- SqlBulkCopyColumnMappingCollection.cs
- VectorValueSerializer.cs
- ItemCollection.cs
- TextRangeBase.cs
- ItemChangedEventArgs.cs
- QueueSurrogate.cs
- WorkflowInstanceUnhandledExceptionRecord.cs
- RowsCopiedEventArgs.cs
- FileChangesMonitor.cs
- ResizeGrip.cs
- WebPartConnectionsCancelVerb.cs
- EncryptedKeyIdentifierClause.cs
- ReflectEventDescriptor.cs
- CallSiteOps.cs
- Object.cs
- PropertyItem.cs
- MemberInitExpression.cs
- SqlGenericUtil.cs
- TypeDescriptionProviderAttribute.cs
- TextLineResult.cs
- StyleSheetComponentEditor.cs
- OuterGlowBitmapEffect.cs
- WaitForChangedResult.cs
- SkewTransform.cs
- Token.cs
- LoginUtil.cs
- StreamReader.cs
- PopupControlService.cs
- LayoutExceptionEventArgs.cs
- TextPatternIdentifiers.cs
- RIPEMD160Managed.cs
- printdlgexmarshaler.cs
- SecurityMode.cs
- ClientScriptManager.cs
- OlePropertyStructs.cs
- ConvertEvent.cs
- KeyConverter.cs
- OperationResponse.cs
- TimeSpanMinutesConverter.cs
- TripleDESCryptoServiceProvider.cs
- SmiRequestExecutor.cs
- OleDbMetaDataFactory.cs
- EmissiveMaterial.cs
- ControlValuePropertyAttribute.cs
- DescendantQuery.cs
- Menu.cs
- SrgsRuleRef.cs
- InternalConfigSettingsFactory.cs
- EdmRelationshipRoleAttribute.cs
- DesignerExtenders.cs
- NetworkInformationException.cs
- DataGridRowClipboardEventArgs.cs
- ItemContainerGenerator.cs
- RewritingValidator.cs
- prompt.cs
- SoapAttributes.cs
- Helper.cs
- UserControlAutomationPeer.cs
- XmlSchemaException.cs
- XmlDomTextWriter.cs
- MessageQueue.cs
- ValidatorCompatibilityHelper.cs
- FontUnit.cs
- CacheRequest.cs
- ProfessionalColors.cs
- DrawingContextDrawingContextWalker.cs
- SemanticBasicElement.cs
- DataServiceKeyAttribute.cs
- ListMarkerSourceInfo.cs
- SecurityPolicySection.cs
- BitConverter.cs
- DatatypeImplementation.cs
- CodeAttributeDeclarationCollection.cs
- WindowsProgressbar.cs
- VectorAnimationBase.cs
- ExpressionEvaluator.cs
- BitmapSizeOptions.cs
- DebugController.cs
- RepeatButtonAutomationPeer.cs
- Helper.cs
- Viewport3DAutomationPeer.cs
- XsltLibrary.cs
- CopyAttributesAction.cs
- XmlUtil.cs
- XsltOutput.cs
- BinaryConverter.cs
- FixedBufferAttribute.cs
- ErrorFormatterPage.cs
- ProcessProtocolHandler.cs
- PreservationFileReader.cs
- MemberHolder.cs
- SecureStringHasher.cs
- COM2IProvidePropertyBuilderHandler.cs
- EncoderFallback.cs