Registers an attached dependency property with the specified property name, property type, owner type, and property metadata for the property.
public: static DependencyProperty^ RegisterAttached( String^ name, TypeName propertyType, TypeName ownerType, PropertyMetadata^ defaultMetadata )
The name of the dependency property to register.
A property metadata instance. This can contain a PropertyChangedCallback implementation reference.
A dependency property identifier that should be used to set the value of a public static read-only field in your class. That identifier is then used to reference the attached property later, for operations such as setting its value programmatically or attaching a Binding.
Tip If you are programming using a .NET language (C# or Microsoft Visual Basic), the TypeName type projects as System.Type. When programming using C#, it is common to use the typeof operator to get references to the System.Type of a type. In Visual Basic, use GetType. If you're using C++/CX), where you'll need to create a TypeName helper struct, you can use the typeid component extension.
This example defines a class that derives from DependencyObject, and defines an attached property along with the identifier field. The scenario for this class is that it is a service class that declares an attached property that other UI elements can set in XAML, and the service potentially acts on the attached property values on those UI elements at run time. For more examples, see Custom attached properties.
Minimum supported client
Minimum supported server
|Windows Server 2012|
- Custom attached properties
- Dependency properties overview
- Attached properties overview
Build date: 12/10/2013