DependencyProperty.GetMetadata DependencyProperty.GetMetadata DependencyProperty.GetMetadata DependencyProperty.GetMetadata Method

定義

傳回與特定類型的此相依性屬性相關聯的中繼資料。Returns the metadata associated with this dependency property as it exists for a particular type. 這可以是第一次註冊相依性屬性的類型 (之後會加一),或透過繼承取得相依性屬性但特別覆寫中繼資料的類型。This can be the type where the dependency property was first registered, one to which it was added subsequently, or a type where the dependency property was obtained through inheritance but the metadata was specifically overridden.

多載

GetMetadata(Type) GetMetadata(Type) GetMetadata(Type) GetMetadata(Type)

傳回這個相依性屬性的中繼資料,因為這個屬性位於指定的現有類型。Returns the metadata for this dependency property as it exists on a specified existing type.

GetMetadata(DependencyObject) GetMetadata(DependencyObject) GetMetadata(DependencyObject)

傳回這個相依性屬性的中繼資料,因為這個屬性位於指定的物件執行個體。Returns the metadata for this dependency property as it exists on the specified object instance.

GetMetadata(DependencyObjectType) GetMetadata(DependencyObjectType) GetMetadata(DependencyObjectType)

傳回存在於所指定類型之這個相依性屬性的中繼資料。Returns the metadata for this dependency property as it exists on a specified type.

GetMetadata(Type) GetMetadata(Type) GetMetadata(Type) GetMetadata(Type)

傳回這個相依性屬性的中繼資料,因為這個屬性位於指定的現有類型。Returns the metadata for this dependency property as it exists on a specified existing type.

public:
 System::Windows::PropertyMetadata ^ GetMetadata(Type ^ forType);
public System.Windows.PropertyMetadata GetMetadata (Type forType);
member this.GetMetadata : Type -> System.Windows.PropertyMetadata
Public Function GetMetadata (forType As Type) As PropertyMetadata

參數

forType
Type Type Type Type

要從中擷取相依性屬性中繼資料的特定類型。The specific type from which to retrieve the dependency property metadata.

傳回

屬性中繼資料物件。A property metadata object.

範例

下列範例會根據型別, 取得相依性屬性的中繼資料。The following example gets metadata for a dependency property based on its type. 型別是使用typeof運算子取得。The type is obtained by using a typeof operator.

pm = MyStateControl.StateProperty.GetMetadata(typeof(MyStateControl));
pm = MyStateControl.StateProperty.GetMetadata(GetType(MyStateControl))

備註

需要指定類型或物件參考當做類型使用, 因為中繼資料可能會因原始註冊AddOwner而異, 因為或OverrideMetadata呼叫會改變存在於類型上之相依性屬性的中繼資料。Specifying either the type or an object reference to use as type is necessary because the metadata can vary from the original registration due either to AddOwner or OverrideMetadata calls that alter the metadata of the dependency property as it exists on a type.

GetMetadata(DependencyObject) GetMetadata(DependencyObject) GetMetadata(DependencyObject)

傳回這個相依性屬性的中繼資料,因為這個屬性位於指定的物件執行個體。Returns the metadata for this dependency property as it exists on the specified object instance.

public:
 System::Windows::PropertyMetadata ^ GetMetadata(System::Windows::DependencyObject ^ dependencyObject);
public System.Windows.PropertyMetadata GetMetadata (System.Windows.DependencyObject dependencyObject);
member this.GetMetadata : System.Windows.DependencyObject -> System.Windows.PropertyMetadata

參數

dependencyObject
DependencyObject DependencyObject DependencyObject DependencyObject

檢查了相依性物件的類型,以判斷中繼資料應該來自於相依性屬性的哪一個特定類型版本。A dependency object that is checked for type, to determine which type-specific version of the dependency property the metadata should come from.

傳回

屬性中繼資料物件。A property metadata object.

範例

下列範例會根據特定DependencyObject實例取得相依性屬性的中繼資料。The following example gets metadata for a dependency property based on a specific DependencyObject instance.

pm = MyAdvancedStateControl.StateProperty.GetMetadata(advancedInstance);
pm = MyAdvancedStateControl.StateProperty.GetMetadata(advancedInstance)

備註

指定類型或物件參考是必要的, 因為任何指定相依性屬性的中繼資料可能與原始註冊AddOwner不同, 因為或OverrideMetadata呼叫可以修改存在於的屬性中繼資料型.Specifying either the type or an object reference is necessary because the metadata of any given dependency property can vary from the original registration due either to AddOwner or OverrideMetadata calls that can refine the property metadata as it exists on a type.

當您要求以實例為基礎的屬性中繼資料時, 您實際上只是傳遞實例, 以便在內部評估其型別。When you request property metadata based on an instance, you are really just passing the instance so that its type can be evaluated internally. 相依性屬性中繼資料不會因每個實例而異;針對任何指定的類型屬性組合, 其一律一致。Dependency property metadata does not vary per instance; it is always consistent for any given type-property combination.

GetMetadata(DependencyObjectType) GetMetadata(DependencyObjectType) GetMetadata(DependencyObjectType)

傳回存在於所指定類型之這個相依性屬性的中繼資料。Returns the metadata for this dependency property as it exists on a specified type.

public:
 System::Windows::PropertyMetadata ^ GetMetadata(System::Windows::DependencyObjectType ^ dependencyObjectType);
public System.Windows.PropertyMetadata GetMetadata (System.Windows.DependencyObjectType dependencyObjectType);
member this.GetMetadata : System.Windows.DependencyObjectType -> System.Windows.PropertyMetadata

參數

dependencyObjectType
DependencyObjectType DependencyObjectType DependencyObjectType DependencyObjectType

記錄需要相依性屬性中繼資料之相依性物件類型的特定物件。A specific object that records the dependency object type from which the dependency property metadata is desired.

傳回

屬性中繼資料物件。A property metadata object.

範例

下列範例會根據其DependencyObjectType, 取得相依性屬性的中繼資料。The following example gets metadata for a dependency property based on its DependencyObjectType.

DependencyObjectType dt = unrelatedInstance.DependencyObjectType;
pm = UnrelatedStateControl.StateProperty.GetMetadata(dt);
Dim dt As DependencyObjectType = unrelatedInstance.DependencyObjectType
pm = UnrelatedStateControl.StateProperty.GetMetadata(dt)

備註

指定類型或物件參考是必要的, 因為任何指定相依性屬性的中繼資料可能與原始註冊AddOwner不同, 因為或OverrideMetadata呼叫可以修改存在於的屬性中繼資料型.Specifying either the type or an object reference is necessary because the metadata of any given dependency property can vary from the original registration due either to AddOwner or OverrideMetadata calls that can refine the property metadata as it exists on a type.

適用於