DependencyProperty.GetMetadata(TypeName) 方法

定義

擷取相依性屬性的屬性中繼資料值,如註冊至類型。 您可以指定要從 中取得資訊的類型做為類型參考。

PropertyMetadata GetMetadata(TypeName const& forType);
public PropertyMetadata GetMetadata(System.Type forType);
function getMetadata(forType)
Public Function GetMetadata (forType As Type) As PropertyMetadata

參數

forType
TypeName Type

要從中擷取相依性屬性中繼資料的特定類型名稱,作為 System.Type for Microsoft .NET 的 System.Type 參考 (,這是 Visual C++ 元件延伸模組的 TypeName 協助程式結構, (C++/CX) ) 。

傳回

屬性中繼資料物件。

範例

此範例會實作公用程式方法,根據登錄並儲存在中繼資料中的預設值,報告 FrameworkElement中存在給定相依性屬性的預設值。

public static object GetDefaultValueForFrameworkDP(DependencyProperty dpIdentifier)
{
    PropertyMetadata metadataInfo = dpIdentifier.GetMetadata(typeof(FrameworkElement));
    return metadataInfo.DefaultValue;
}
Public Shared Function GetDefaultValueForFrameworkDP(dpIdentifier As DependencyProperty) As Object
    Dim metadataInfo As PropertyMetadata = dpIdentifier.GetMetadata(GetType(FrameworkElement))
    GetDefaultValueForFrameworkDP = metadataInfo.DefaultValue
End Function

適用於

另請參閱