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 / AttachedPropertyBrowsableForChildrenAttribute.cs / 1 / 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
- DesignerCommandSet.cs
- OdbcParameterCollection.cs
- TextEditorTables.cs
- XamlFigureLengthSerializer.cs
- VariableQuery.cs
- UndirectedGraph.cs
- XmlWellformedWriterHelpers.cs
- Debug.cs
- ThrowOnMultipleAssignment.cs
- RegistryKey.cs
- IsolatedStorageFilePermission.cs
- TdsRecordBufferSetter.cs
- HierarchicalDataTemplate.cs
- EmptyStringExpandableObjectConverter.cs
- CellPartitioner.cs
- XmlSortKey.cs
- RegisteredHiddenField.cs
- StorageComplexPropertyMapping.cs
- ListView.cs
- EqualityArray.cs
- XslVisitor.cs
- DependsOnAttribute.cs
- MailBnfHelper.cs
- LocalTransaction.cs
- Shape.cs
- RequiredAttributeAttribute.cs
- GridLength.cs
- TileModeValidation.cs
- RoleService.cs
- UnaryNode.cs
- SimpleTypesSurrogate.cs
- UICuesEvent.cs
- SimpleExpression.cs
- TableLayoutPanelCodeDomSerializer.cs
- ProcessModule.cs
- DurableRuntimeValidator.cs
- _ContextAwareResult.cs
- TextTreeFixupNode.cs
- RegexWorker.cs
- MSHTMLHost.cs
- GlyphTypeface.cs
- ByteRangeDownloader.cs
- unsafenativemethodstextservices.cs
- MultipleViewProviderWrapper.cs
- DecimalStorage.cs
- ResumeStoryboard.cs
- PropertyDescriptorGridEntry.cs
- WindowsFormsSynchronizationContext.cs
- AssociationType.cs
- Models.cs
- _CookieModule.cs
- NativeConfigurationLoader.cs
- DrawingContextDrawingContextWalker.cs
- CalendarItem.cs
- EventHandlersStore.cs
- XmlCharCheckingWriter.cs
- TextBoxBase.cs
- BrowserCapabilitiesFactoryBase.cs
- ResourceContainer.cs
- NameValueConfigurationElement.cs
- PropertyChangedEventArgs.cs
- BackgroundWorker.cs
- FileIOPermission.cs
- FilterException.cs
- CustomWebEventKey.cs
- DiscoveryProxy.cs
- RecognizerStateChangedEventArgs.cs
- SHA384.cs
- DictionaryManager.cs
- validation.cs
- MessageSecurityVersionConverter.cs
- GeneratedView.cs
- AvTraceDetails.cs
- TemplateContentLoader.cs
- CacheDependency.cs
- FunctionNode.cs
- RecordConverter.cs
- Win32.cs
- PipelineModuleStepContainer.cs
- FunctionDefinition.cs
- ResourcePermissionBaseEntry.cs
- SecureEnvironment.cs
- Literal.cs
- JsonWriter.cs
- contentDescriptor.cs
- FocusTracker.cs
- BamlBinaryReader.cs
- PageThemeCodeDomTreeGenerator.cs
- ListItemCollection.cs
- FullTextLine.cs
- WebServiceFault.cs
- ZipIOBlockManager.cs
- SystemIcons.cs
- DiffuseMaterial.cs
- MetadataStore.cs
- ToolStripControlHost.cs
- HttpCookieCollection.cs
- ByteAnimation.cs
- EncoderBestFitFallback.cs
- RoleGroupCollection.cs