Represents a property that can be set through methods such as, styling, data binding, animation, and inheritance.
public ref class DependencyProperty sealed
[System.ComponentModel.TypeConverter("System.Windows.Markup.DependencyPropertyConverter, PresentationFramework, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")] [System.ComponentModel.TypeConverter("System.Windows.Markup.DependencyPropertyConverter, PresentationFramework, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")] public sealed class DependencyProperty
type DependencyProperty = class
Public NotInheritable Class DependencyProperty
A DependencyProperty supports the following capabilities in Windows Presentation Foundation (WPF):
The property can be set in a style. For more information, see Styling and Templating.
The property can be set through data binding. For more information about data binding dependency properties, see How to: Bind the Properties of Two Controls.
The property can be set with a dynamic resource reference. For more information, see XAML Resources.
The property can inherit its value automatically from a parent element in the element tree. For more information, see Property Value Inheritance.
The property can be animated. For more information, see Animation Overview.
The property can report when the previous value of the property has been changed and the property value can be coerced. For more information, see Dependency Property Callbacks and Validation.
The property reports information to WPF, such as whether changing a property value should require the layout system to recompose the visuals for an element.
The property receives support in the WPF Designer for Visual Studio. For example, the property can be edited in the Properties window.
To learn more about dependency properties, see Dependency Properties Overview. If you want properties on your custom types to support the capabilities in the preceding list, you should create a dependency property. To learn how to create custom dependency properties, see Custom Dependency Properties.
An attached property is a property that enables any object to report information to the type that defines the attached property. In WPF, any type that inherits from DependencyObject can use an attached property regardless of whether the type inherits from the type that defines the property. An attached property is a feature of the XAML language. To set an attached property in XAML, use the ownerType.propertyName syntax. An example of an attached property is the DockPanel.Dock property. If you want to create a property that can be used on all DependencyObject types, then you should create an attached property. To learn more about attached properties, including how to create them, see Attached Properties Overview.
XAML Attribute Usage
A string that specifies the DependencyProperty.Name of the desired dependency property. This can be preceded by an XML namespace prefix if the property is not in the default XML namespace (for details, see XAML Namespaces and Namespace Mapping for WPF XAML.)
A string that specifies an owner type of a dependency property, a dot (.), then the DependencyProperty.Name.
ownerType can also be preceded by an XML namespace prefix. This usage is particular to late-bound styles and templates, where the owner of the dependency property must be specified for parsing context because the
TargetType is not yet known. For more information, see Styling and Templating.
A string that specifies the owner of an attached property, a dot (.), then the attached property name.
attachedPropertyOwnerType can also be preceded by an XML namespace prefix.
|UnsetValue UnsetValue UnsetValue UnsetValue||
Specifies a static value that is used by the WPF property system rather than
|DefaultMetadata DefaultMetadata DefaultMetadata DefaultMetadata||
Gets the default metadata of the dependency property.
|GlobalIndex GlobalIndex GlobalIndex GlobalIndex||
Gets an internally generated value that uniquely identifies the dependency property.
|Name Name Name Name||
Gets the name of the dependency property.
|OwnerType OwnerType OwnerType OwnerType||
Gets the type of the object that registered the dependency property with the property system, or added itself as owner of the property.
|PropertyType PropertyType PropertyType PropertyType||
Gets the type that the dependency property uses for its value.
|ReadOnly ReadOnly ReadOnly ReadOnly||
Gets a value that indicates whether the dependency property identified by this DependencyProperty instance is a read-only dependency property.
|ValidateValueCallback ValidateValueCallback ValidateValueCallback ValidateValueCallback||
Gets the value validation callback for the dependency property.