dependencyPropertyName A string that specifies the DependencyProperty.Name of the desired dependency property. This can be preceded by a prefix if the property is not in the default xmlns namespace (for details, see XAML Namespaces and Namespace Mapping.) ownerType.dependencyPropertyName A string that specifies an owner type of a dependency property, a dot (.), then the DependencyProperty.Name. ownerType can also be preceded by a 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. attachedPropertyOwnerType.attachedPropertyName A string that specifies the owner of an attached property, a dot (.), then the attached property name. attachedPropertyOwnerType can also be preceded by a prefix.

If you want properties on your custom types to support value expressions, property invalidation, per-type default values, inheritance, data binding, animation, or styling, you should back these CLR properties with a dependency property following these guidelines and procedures:

Register a dependency property using the Register method; this method returns a DependencyProperty, which you should store as an accessible static read-only field in your class. By convention, the name of this DependencyProperty identifier field should end with Property, and this convention is followed by all dependency properties implemented in WPF. For example, the Control.Background dependency property is identified by the Control.BackgroundProperty field.

During registration, you can provide PropertyMetadata for the property to further define the property's behaviors, including its default value and callbacks that can be used to modify the property value in accordance to changes in related property values.

Provide common language runtime (CLR) accessors for the property.

If you want to create a property that can be used on all DependencyObject types regardless of whether they are within the derived class list of the class that defines the property, then you should create an attached property. An example of an attached property is the DockPanel.Dock property. For details, see Attached Properties Overview.

This example shows how to back a common language runtime (CLR) property with a DependencyProperty field, thus defining a dependency property. When you define your own properties and want them to support many aspects of Windows Presentation Foundation (WPF) functionality, including styles, data binding, inheritance, animation, and default values, you should implement them as a dependency property.

The following example first registers a dependency property by calling the Register method. The name of the identifier field that you use to store the name and characteristics of the dependency property must be the Name you chose for the dependency property as part of the Register call, appended by the literal string Property. For instance, if you register a dependency property with a Name of Location, then the identifier field that you define for the dependency property must be named LocationProperty.

In this example, the name of the dependency property and its CLR accessor is State; the identifier field is StateProperty; the type of the property is Boolean; and the type that registers the dependency property is MyStateControl.

If you fail to follow this naming pattern, designers might not report your property correctly, and certain aspects of property system style application might not behave as expected.

You can also specify default metadata for a dependency property. This example registers the default value of the State dependency property to be false.