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
- CoTaskMemHandle.cs
- _UriTypeConverter.cs
- TextModifier.cs
- XmlMembersMapping.cs
- DeploymentSection.cs
- SyndicationContent.cs
- MultiPageTextView.cs
- DragDropHelper.cs
- CSharpCodeProvider.cs
- OutputScopeManager.cs
- MissingSatelliteAssemblyException.cs
- DuplicateWaitObjectException.cs
- DataServiceProviderWrapper.cs
- DbConnectionPoolGroup.cs
- keycontainerpermission.cs
- WhileDesigner.cs
- AutomationEvent.cs
- ButtonBaseDesigner.cs
- OrderedDictionaryStateHelper.cs
- DBConcurrencyException.cs
- AddInIpcChannel.cs
- BitmapEffectCollection.cs
- XsdDuration.cs
- PropagatorResult.cs
- SqlCacheDependencySection.cs
- QueryExecutionOption.cs
- Material.cs
- X509CertificateChain.cs
- BoundField.cs
- SatelliteContractVersionAttribute.cs
- PathStreamGeometryContext.cs
- SessionState.cs
- ReachFixedDocumentSerializerAsync.cs
- NestedContainer.cs
- EnvironmentPermission.cs
- PolyBezierSegment.cs
- GridViewCommandEventArgs.cs
- ToolboxItemLoader.cs
- ProjectionPruner.cs
- ActiveXSite.cs
- WorkflowDebuggerSteppingAttribute.cs
- WebPartRestoreVerb.cs
- WindowsSecurityToken.cs
- TextBox.cs
- LocalFileSettingsProvider.cs
- DataControlImageButton.cs
- MessageBuilder.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- BitStack.cs
- ActivityCodeDomSerializationManager.cs
- DeploymentSection.cs
- FtpWebResponse.cs
- SR.cs
- SizeChangedInfo.cs
- Literal.cs
- StringArrayConverter.cs
- Vector3DValueSerializer.cs
- RichListBox.cs
- FieldTemplateFactory.cs
- StrokeCollection.cs
- KnowledgeBase.cs
- RightsManagementSuppressedStream.cs
- dataobject.cs
- DateTimeOffsetAdapter.cs
- WindowsBrush.cs
- CodeBinaryOperatorExpression.cs
- DataGridCellsPresenter.cs
- ClientApiGenerator.cs
- ThreadSafeMessageFilterTable.cs
- DiagnosticTraceSchemas.cs
- ListViewDataItem.cs
- EncryptedPackage.cs
- SimpleColumnProvider.cs
- TimeEnumHelper.cs
- RectAnimationClockResource.cs
- AliasedExpr.cs
- MessageDecoder.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- ProgressBarRenderer.cs
- CookieParameter.cs
- PropertySegmentSerializationProvider.cs
- RoleManagerEventArgs.cs
- TokenBasedSet.cs
- ControlPropertyNameConverter.cs
- UxThemeWrapper.cs
- PkcsUtils.cs
- TerminatorSinks.cs
- SqlBulkCopy.cs
- RangeValueProviderWrapper.cs
- ValidationEventArgs.cs
- BitmapEffectInput.cs
- Ref.cs
- smtppermission.cs
- ReadOnlyHierarchicalDataSource.cs
- TreeNodeStyle.cs
- FixedTextBuilder.cs
- HtmlTableCellCollection.cs
- ArgumentsParser.cs
- SegmentInfo.cs
- ToolStripItemClickedEventArgs.cs