Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BitConverter.cs
- _BaseOverlappedAsyncResult.cs
- PropertyHelper.cs
- ByteStack.cs
- AutomationIdentifierGuids.cs
- TreeNodeBindingCollection.cs
- WebHttpDispatchOperationSelector.cs
- XmlSchemaRedefine.cs
- WebPartZoneAutoFormat.cs
- CryptoProvider.cs
- RoleGroup.cs
- SQLDouble.cs
- CodeTypeReferenceCollection.cs
- ArgumentOutOfRangeException.cs
- UniformGrid.cs
- X509SecurityTokenAuthenticator.cs
- EncryptedData.cs
- SelectedCellsCollection.cs
- BoolExpression.cs
- DbConnectionPoolGroupProviderInfo.cs
- SystemResourceKey.cs
- FontEmbeddingManager.cs
- XhtmlConformanceSection.cs
- ArrangedElementCollection.cs
- InputScopeNameConverter.cs
- KeyFrames.cs
- SectionRecord.cs
- SingleQueryOperator.cs
- AggregateException.cs
- PeerNameRegistration.cs
- VisualTreeUtils.cs
- HttpWebRequest.cs
- nulltextcontainer.cs
- BindingUtils.cs
- Animatable.cs
- AliasedSlot.cs
- SymbolEqualComparer.cs
- DetailsViewRow.cs
- GeneralTransform3DTo2DTo3D.cs
- OperationInvokerTrace.cs
- RenamedEventArgs.cs
- ImpersonateTokenRef.cs
- ReliableInputConnection.cs
- DateTimeValueSerializer.cs
- FormatConvertedBitmap.cs
- ParameterReplacerVisitor.cs
- RectConverter.cs
- EnglishPluralizationService.cs
- ExecutionContext.cs
- Geometry3D.cs
- RSAPKCS1SignatureDeformatter.cs
- CacheHelper.cs
- XmlRawWriter.cs
- Pkcs7Recipient.cs
- UpdatePanel.cs
- ScriptControlDescriptor.cs
- SizeChangedEventArgs.cs
- MobileControlDesigner.cs
- SizeAnimationClockResource.cs
- ReceiveSecurityHeader.cs
- RequestCache.cs
- MediaElement.cs
- UpdateEventArgs.cs
- MouseDevice.cs
- SettingsContext.cs
- ContainerSelectorBehavior.cs
- TextModifierScope.cs
- DragCompletedEventArgs.cs
- XmlSchemaNotation.cs
- PerformanceCounterPermissionAttribute.cs
- FontConverter.cs
- ExpandableObjectConverter.cs
- ColorContextHelper.cs
- FigureHelper.cs
- indexingfiltermarshaler.cs
- BinaryFormatterSinks.cs
- ResourcePool.cs
- FileSystemEventArgs.cs
- SystemIPAddressInformation.cs
- FixedSOMPageElement.cs
- TraceProvider.cs
- WebServiceHandler.cs
- Symbol.cs
- CodeIndexerExpression.cs
- XamlPathDataSerializer.cs
- SafeReadContext.cs
- BufferModesCollection.cs
- HttpHandler.cs
- AssemblyNameProxy.cs
- EntityRecordInfo.cs
- SharedDp.cs
- WorkflowTransactionService.cs
- MenuEventArgs.cs
- XmlSchemaType.cs
- XsdDuration.cs
- SemanticAnalyzer.cs
- XhtmlBasicPanelAdapter.cs
- ButtonAutomationPeer.cs
- NumberSubstitution.cs
- TreeNodeBinding.cs