Registers a dependency property with the specified property name, property type, owner type, and property metadata for the property.
Public Shared Function Register( name As String, propertyType As Type, ownerType As Type, typeMetadata As PropertyMetadata ) As DependencyProperty
The name of the dependency property to register.
The type of the property.
The owner type that is registering the dependency property.
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. The identifier is then used both by your own code and any third-party user code to reference the dependency property later, for operations such as setting its value programmatically or attaching a Binding in code.
If you are programming using a Microsoft .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.
This example shows a basic usage where a DependencyProperty is established as a public static member of a class. This is done by calling DependencyProperty.Register and storing the return value. For more examples, including a C++/CX example, see Custom dependency properties.
Public Class Fish Inherits Control Public Shared ReadOnly SpeciesProperty As DependencyProperty = _ DependencyProperty.Register( "Species", _ GetType(String), _ GetType(Fish), _ Nothing) Public Property Species As String Get Species = CType(GetValue(SpeciesProperty), String) End Get Set(value As String) SetValue(SpeciesProperty, value) End Set End Property End Class
Minimum supported client
Minimum supported server
|Windows Server 2012|
- Custom dependency properties
- Dependency properties overview
- XAML user and custom controls sample
Build date: 11/16/2013