Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / AttachedPropertyBrowsableForChildrenAttribute.cs / 1305600 / AttachedPropertyBrowsableForChildrenAttribute.cs
namespace System.Windows { using System; ////// This attribute declares that a property is visible when the /// property owner is a parent of another element. For example, /// Canvas.Left is only useful on elements parented within the /// canvas. The class supports two types of tree walks: a shallow /// walk, the default which requires that the immediate parent be the /// owner type of the property, and a deep walk, declared by setting /// IncludeDescendants to true and requires that the owner type be /// somewhere in the parenting hierarchy. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public sealed class AttachedPropertyBrowsableForChildrenAttribute : AttachedPropertyBrowsableAttribute { //------------------------------------------------------ // // Constructors // //----------------------------------------------------- ////// Creates a new AttachedPropertyBrowsableForChildrenAttribute. /// public AttachedPropertyBrowsableForChildrenAttribute() { } //----------------------------------------------------- // // Public Properties // //----------------------------------------------------- ////// Gets or sets if the property should be browsable for just the /// immediate children (false) or all children (true). /// public bool IncludeDescendants { get { return _includeDescendants; } set { _includeDescendants = value; } } //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- ////// Overrides Object.Equals to implement correct equality semantics for this /// attribute. /// public override bool Equals(object obj) { AttachedPropertyBrowsableForChildrenAttribute other = obj as AttachedPropertyBrowsableForChildrenAttribute; if (other == null) return false; return _includeDescendants == other._includeDescendants; } ////// Overrides Object.GetHashCode to implement correct hashing semantics. /// public override int GetHashCode() { return _includeDescendants.GetHashCode(); } //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ ////// Returns true if the object provided is the immediate logical /// child (if IncludeDescendants is false) or any logical child /// (if IncludeDescendants is true). /// internal override bool IsBrowsable(DependencyObject d, DependencyProperty dp) { if (d == null) throw new ArgumentNullException("d"); if (dp == null) throw new ArgumentNullException("dp"); DependencyObject walk = d; Type ownerType = dp.OwnerType; do { walk = FrameworkElement.GetFrameworkParent(walk); if (walk != null && ownerType.IsInstanceOfType(walk)) { return true; } } while (_includeDescendants && walk != null); return false; } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ private bool _includeDescendants; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Windows { using System; ////// This attribute declares that a property is visible when the /// property owner is a parent of another element. For example, /// Canvas.Left is only useful on elements parented within the /// canvas. The class supports two types of tree walks: a shallow /// walk, the default which requires that the immediate parent be the /// owner type of the property, and a deep walk, declared by setting /// IncludeDescendants to true and requires that the owner type be /// somewhere in the parenting hierarchy. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public sealed class AttachedPropertyBrowsableForChildrenAttribute : AttachedPropertyBrowsableAttribute { //------------------------------------------------------ // // Constructors // //----------------------------------------------------- ////// Creates a new AttachedPropertyBrowsableForChildrenAttribute. /// public AttachedPropertyBrowsableForChildrenAttribute() { } //----------------------------------------------------- // // Public Properties // //----------------------------------------------------- ////// Gets or sets if the property should be browsable for just the /// immediate children (false) or all children (true). /// public bool IncludeDescendants { get { return _includeDescendants; } set { _includeDescendants = value; } } //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- ////// Overrides Object.Equals to implement correct equality semantics for this /// attribute. /// public override bool Equals(object obj) { AttachedPropertyBrowsableForChildrenAttribute other = obj as AttachedPropertyBrowsableForChildrenAttribute; if (other == null) return false; return _includeDescendants == other._includeDescendants; } ////// Overrides Object.GetHashCode to implement correct hashing semantics. /// public override int GetHashCode() { return _includeDescendants.GetHashCode(); } //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ ////// Returns true if the object provided is the immediate logical /// child (if IncludeDescendants is false) or any logical child /// (if IncludeDescendants is true). /// internal override bool IsBrowsable(DependencyObject d, DependencyProperty dp) { if (d == null) throw new ArgumentNullException("d"); if (dp == null) throw new ArgumentNullException("dp"); DependencyObject walk = d; Type ownerType = dp.OwnerType; do { walk = FrameworkElement.GetFrameworkParent(walk); if (walk != null && ownerType.IsInstanceOfType(walk)) { return true; } } while (_includeDescendants && walk != null); return false; } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ private bool _includeDescendants; } } // 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
- DataControlHelper.cs
- SingleObjectCollection.cs
- SiteMapNodeItemEventArgs.cs
- EventBindingService.cs
- SHA384Managed.cs
- AssociationType.cs
- WindowsSysHeader.cs
- CatalogPartChrome.cs
- FixedSOMPageElement.cs
- OutputCacheSection.cs
- TextElement.cs
- Baml2006SchemaContext.cs
- InputReport.cs
- PromptEventArgs.cs
- CompressionTransform.cs
- ColumnWidthChangedEvent.cs
- ViewStateException.cs
- ReflectEventDescriptor.cs
- EventToken.cs
- ElementUtil.cs
- TextRangeProviderWrapper.cs
- InputLanguageSource.cs
- CategoryGridEntry.cs
- CurrentChangingEventManager.cs
- FormsAuthentication.cs
- IItemProperties.cs
- SchemeSettingElement.cs
- FunctionImportMapping.cs
- BinaryMessageEncodingBindingElement.cs
- CustomError.cs
- MsmqDecodeHelper.cs
- OdbcParameter.cs
- SqlError.cs
- HierarchicalDataSourceConverter.cs
- IndexingContentUnit.cs
- ArrayTypeMismatchException.cs
- QilParameter.cs
- HandlerWithFactory.cs
- TCEAdapterGenerator.cs
- OdbcUtils.cs
- NullRuntimeConfig.cs
- DbUpdateCommandTree.cs
- RadioButton.cs
- TypeConverterValueSerializer.cs
- MsmqVerifier.cs
- StringUtil.cs
- RelationshipConverter.cs
- IERequestCache.cs
- SmiEventSink_DeferedProcessing.cs
- WorkItem.cs
- RangeExpression.cs
- StylusOverProperty.cs
- EventToken.cs
- MessageQueuePermissionEntry.cs
- WindowsImpersonationContext.cs
- ComponentEditorPage.cs
- BitmapSizeOptions.cs
- ConstraintConverter.cs
- DataSourceView.cs
- StrokeCollection2.cs
- ConfigurationStrings.cs
- SocketInformation.cs
- CapabilitiesRule.cs
- SaveWorkflowCommand.cs
- PropertiesTab.cs
- Semaphore.cs
- TreeViewBindingsEditor.cs
- IUnknownConstantAttribute.cs
- XmlDataSourceNodeDescriptor.cs
- SequenceDesignerAccessibleObject.cs
- RoleManagerEventArgs.cs
- ToolStripItemEventArgs.cs
- __FastResourceComparer.cs
- AuthenticationModuleElement.cs
- PropertyManager.cs
- MatrixIndependentAnimationStorage.cs
- BamlReader.cs
- WebPartExportVerb.cs
- HttpContext.cs
- MembershipUser.cs
- ParamArrayAttribute.cs
- TypeDescriptor.cs
- QilDataSource.cs
- TextBoxAutoCompleteSourceConverter.cs
- SymLanguageVendor.cs
- DrawingGroup.cs
- WeakEventTable.cs
- _FixedSizeReader.cs
- ConfigurationSettings.cs
- GraphicsPath.cs
- ListItemParagraph.cs
- SettingsPropertyIsReadOnlyException.cs
- HeaderLabel.cs
- UTF32Encoding.cs
- XamlFigureLengthSerializer.cs
- SchemaImporterExtension.cs
- DataGridViewRowCollection.cs
- ImageConverter.cs
- ErrorFormatter.cs
- InvokeWebServiceDesigner.cs