Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- MailHeaderInfo.cs
- BCryptNative.cs
- FindResponse.cs
- XmlSchemaType.cs
- VScrollBar.cs
- HttpContext.cs
- DesignerDataRelationship.cs
- CompiledIdentityConstraint.cs
- HideDisabledControlAdapter.cs
- GeneralTransform.cs
- NativeWindow.cs
- WebDescriptionAttribute.cs
- XmlNodeReader.cs
- TextTreeExtractElementUndoUnit.cs
- TiffBitmapEncoder.cs
- DataGridViewTopRowAccessibleObject.cs
- CultureTableRecord.cs
- EventListenerClientSide.cs
- TemplateField.cs
- HMACSHA256.cs
- StdValidatorsAndConverters.cs
- SQLChars.cs
- AccessorTable.cs
- PinnedBufferMemoryStream.cs
- EventMappingSettings.cs
- DetailsViewUpdatedEventArgs.cs
- DesignBinding.cs
- XmlSchemaSimpleTypeRestriction.cs
- ContainerAction.cs
- SimpleMailWebEventProvider.cs
- EventManager.cs
- ClientBuildManager.cs
- TileModeValidation.cs
- ClusterRegistryConfigurationProvider.cs
- PaintValueEventArgs.cs
- StylusShape.cs
- ParenthesizePropertyNameAttribute.cs
- ErrorHandler.cs
- MouseOverProperty.cs
- CopyNodeSetAction.cs
- HtmlInputCheckBox.cs
- ObjectDataSourceFilteringEventArgs.cs
- HexParser.cs
- HtmlForm.cs
- ObjectQuery.cs
- VScrollBar.cs
- CompilerInfo.cs
- AtomServiceDocumentSerializer.cs
- HashHelper.cs
- StateMachineHelpers.cs
- ComponentRenameEvent.cs
- ConstraintEnumerator.cs
- HandleValueEditor.cs
- Int32AnimationBase.cs
- Message.cs
- LostFocusEventManager.cs
- CommandBindingCollection.cs
- PersonalizableTypeEntry.cs
- ProtocolsConfiguration.cs
- XsltArgumentList.cs
- MetadataSource.cs
- complextypematerializer.cs
- DataKey.cs
- SymmetricKey.cs
- PackageDigitalSignatureManager.cs
- RefreshEventArgs.cs
- ContextInformation.cs
- WindowsNonControl.cs
- HelpEvent.cs
- NetTcpSection.cs
- TripleDES.cs
- PermissionRequestEvidence.cs
- DLinqDataModelProvider.cs
- DefaultValueMapping.cs
- PnrpPermission.cs
- QuerySettings.cs
- QueryStack.cs
- X509Certificate2Collection.cs
- AssociationEndMember.cs
- FixedSOMLineCollection.cs
- DateTimePickerDesigner.cs
- ValueQuery.cs
- DataControlCommands.cs
- FileNotFoundException.cs
- SqlDataSource.cs
- PageCodeDomTreeGenerator.cs
- XsltConvert.cs
- NegotiationTokenProvider.cs
- XhtmlBasicLinkAdapter.cs
- XLinq.cs
- VectorCollection.cs
- ItemChangedEventArgs.cs
- CodeDomExtensionMethods.cs
- BasicExpressionVisitor.cs
- WmlObjectListAdapter.cs
- Enum.cs
- SpeechUI.cs
- MSAAWinEventWrap.cs
- DataGridViewRowCancelEventArgs.cs
- TimeStampChecker.cs