DependencyProperty.PropertyType 屬性

定義

取得相依性屬性用於其值的型別。Gets the type that the dependency property uses for its value.

public:
 property Type ^ PropertyType { Type ^ get(); };
public Type PropertyType { get; }
member this.PropertyType : Type
Public ReadOnly Property PropertyType As Type

屬性值

屬性值的 TypeThe Type of the property value.

範例

下列範例會查詢相依性屬性識別碼的各種特性,包括 PropertyTypeThe following example queries various characteristics of a dependency property identifier, including the PropertyType. PropertyType 的類型名稱字串是從傳回的 Type取得。The type name string of the PropertyType is obtained from the returned Type.

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")

備註

這個屬性會透過 propertyType 參數,報告由原始屬性註冊所宣告的屬性值類型。This property reports the type of the property's value as declared by the original property registration, through the propertyType parameter. 類似于 Name,相依性屬性的屬性類型在註冊之後是不可變的。Similar to the Name, the property type of a dependency property is immutable after registration.

適用於