Dela via


DependencyProperty.GetMetadata(TypeName) Method

Definition

Retrieves the property metadata value for the dependency property as registered to a type. You specify the type you want info from as a type reference.

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

Parameters

forType
TypeName Type

The name of the specific type from which to retrieve the dependency property metadata, as a type reference (System.Type for Microsoft .NET, a TypeName helper struct for Visual C++ component extensions (C++/CX)).

Returns

A property metadata object.

Examples

This example implements a utility method that reports the default value of a given dependency property as it exists in FrameworkElement, based on the default value registered and stored in the metadata.

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

Applies to

See also