This topic has not yet been rated - Rate this topic

DependencyProperty.Name Property

Gets the name of the dependency property.

Namespace:  System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)
'Declaration
Public ReadOnly Property Name As String

Property Value

Type: System.String
The name of the property.

This property gets the name provided as the name parameter during dependency property registration. This name is immutable, and cannot be Nothing or an empty string. Duplicate name registrations on the same owner type are not permitted, and will throw an exception when you attempt to register the duplicate.

Important noteImportant

The Name of a dependency property must follow the convention of matching the name of its dependency property identifier minus the suffix "Property". For details, see Custom Dependency Properties.

The following example queries various characteristics of a dependency property identifier, including the Name.

		pm = dp.GetMetadata(dp.OwnerType)
		MetadataClass.Text = pm.GetType().Name
		TypeofPropertyValue.Text = dp.PropertyType.Name
		DefaultPropertyValue.Text = If((pm.DefaultValue IsNot Nothing), pm.DefaultValue.ToString(), "null")
		HasCoerceValue.Text = If((pm.CoerceValueCallback Is Nothing), "No", pm.CoerceValueCallback.Method.Name)
		HasPropertyChanged.Text = If((pm.PropertyChangedCallback Is Nothing), "No", pm.PropertyChangedCallback.Method.Name)
            [ReadOnly].Text = If((dp.ReadOnly), "Yes", "No")

More Code

How to: Implement a Dependency PropertyThis 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.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.