Export (0) Print
Expand All

DependencyProperty.Name Property

Gets the name of the dependency property.

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

public string Name { get; }

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 null 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 = (pm.DefaultValue!=null) ? pm.DefaultValue.ToString() : "null";
HasCoerceValue.Text = (pm.CoerceValueCallback == null) ? "No" : pm.CoerceValueCallback.Method.Name;
HasPropertyChanged.Text = (pm.PropertyChangedCallback == null) ? "No" : pm.PropertyChangedCallback.Method.Name;
ReadOnly.Text = (dp.ReadOnly) ? "Yes" : "No";

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft