DependencyProperty.Name Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the name of the dependency property.
public:
property System::String ^ Name { System::String ^ get(); };
public string Name { get; }
member this.Name : string
Public ReadOnly Property Name As String
Property Value
The name of the property.
Examples
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";
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")
Remarks
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
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.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈