Register Method
Collapse the table of content
Expand the table of content

DependencyProperty.Register Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Registers a dependency property with the specified property name, property type, owner type, and property metadata for the property.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

public static DependencyProperty Register(
	string name,
	Type propertyType,
	Type ownerType,
	PropertyMetadata typeMetadata


Type: System.String
The name of the dependency property to register.
Type: System.Type
The type of the property.
Type: System.Type
The owner type that is registering the dependency property.
Type: System.Windows.PropertyMetadata
A property metadata instance. This can contain a PropertyChangedCallback implementation reference.

Return Value

Type: System.Windows.DependencyProperty
A dependency property identifier that should be used to set the value of a public static readonly 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.


A required parameter was null (check the exception for the name of the missing parameter).


A parameter was out of range, for instance name was an empty string.


Attempted to register with a propertyType that does not match a default value specified in the typeMetadata.

Dependency property concepts are covered in detail in the topic Dependency properties for Windows Phone 8.

If you do not need property metadata for your dependency property, specify typeMetadata as null.

Windows Phone does not support custom read-only dependency properties. For details, see Dependency properties for Windows Phone 8.

Important noteImportant Note:

Do not register a dependency property with the specific default value of UnsetValue. This will be confusing for property consumers and will have unintended consequences within the property system.

The following example shows a basic usage where a DependencyProperty is established as a public static member of a class. This is done by calling Register and storing the return value.

public static readonly DependencyProperty IsSpinningProperty = 
    "IsSpinning", typeof(Boolean),
    typeof(SilverlightExampleClass), null
public bool IsSpinning
    get { return (bool)GetValue(IsSpinningProperty); }
    set { SetValue(IsSpinningProperty, value); }

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft