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
- AssemblyEvidenceFactory.cs
- DynamicDocumentPaginator.cs
- RegexStringValidatorAttribute.cs
- CommittableTransaction.cs
- RunInstallerAttribute.cs
- PixelFormats.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- HttpResponseWrapper.cs
- UpDownEvent.cs
- MessageSecurityVersionConverter.cs
- PtsPage.cs
- HtmlControl.cs
- ContentType.cs
- TemplateComponentConnector.cs
- SpnegoTokenProvider.cs
- DSGeneratorProblem.cs
- BindingCollection.cs
- PropertyPath.cs
- MemberHolder.cs
- AsyncCompletedEventArgs.cs
- XamlToRtfWriter.cs
- XXXOnTypeBuilderInstantiation.cs
- InputQueueChannelAcceptor.cs
- BufferAllocator.cs
- XmlSchemaParticle.cs
- XamlInt32CollectionSerializer.cs
- DefaultSection.cs
- JsonUriDataContract.cs
- XmlUtf8RawTextWriter.cs
- FixedPageStructure.cs
- FactoryGenerator.cs
- ServicePointManagerElement.cs
- TextCharacters.cs
- CssTextWriter.cs
- InvariantComparer.cs
- QilTargetType.cs
- TextServicesDisplayAttribute.cs
- CheckBox.cs
- Context.cs
- FirstMatchCodeGroup.cs
- MachineKey.cs
- PriorityRange.cs
- FrameworkTemplate.cs
- CreateUserWizardStep.cs
- DataRecordInternal.cs
- CommandBindingCollection.cs
- FixedSOMImage.cs
- TextDecorationLocationValidation.cs
- TCEAdapterGenerator.cs
- MsmqIntegrationProcessProtocolHandler.cs
- HttpPostedFile.cs
- bindurihelper.cs
- RepeaterItemCollection.cs
- Comparer.cs
- TextEditorContextMenu.cs
- ErrorActivity.cs
- EntityDataSourceViewSchema.cs
- CallTemplateAction.cs
- XmlUnspecifiedAttribute.cs
- IndexedGlyphRun.cs
- SmiTypedGetterSetter.cs
- AllMembershipCondition.cs
- DescriptionAttribute.cs
- LookupBindingPropertiesAttribute.cs
- peersecurityelement.cs
- ReservationNotFoundException.cs
- ObjectTag.cs
- Calendar.cs
- Point3DValueSerializer.cs
- ListViewCancelEventArgs.cs
- OracleTimeSpan.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ToolStripDropDown.cs
- PropertyValueChangedEvent.cs
- DataGridLinkButton.cs
- Win32MouseDevice.cs
- _BaseOverlappedAsyncResult.cs
- PreservationFileReader.cs
- PathStreamGeometryContext.cs
- CircleHotSpot.cs
- OptimizerPatterns.cs
- StrokeNode.cs
- ShaderEffect.cs
- Rotation3DAnimationBase.cs
- DictionaryContent.cs
- UserControl.cs
- XmlBinaryReader.cs
- Utils.cs
- ProjectionPlan.cs
- PrintSchema.cs
- SegmentTree.cs
- InvalidOperationException.cs
- InsufficientMemoryException.cs
- RandomDelayQueuedSendsAsyncResult.cs
- TreeWalkHelper.cs
- HttpPostLocalhostServerProtocol.cs
- PeerPresenceInfo.cs
- Restrictions.cs
- Privilege.cs
- AuthenticationConfig.cs