DependencyProperty.GetMetadata method

Applies to Windows and Windows Phone

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.

Syntax


public PropertyMetadata GetMetadata(
  Type forType
)

Parameters

forType

Type: System.Type [.NET] | TypeName [C++]

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

Return value

Type: PropertyMetadata

A property metadata object.

Remarks

Note  If you are programming using a .NET language (C# or Microsoft Visual Basic), the TypeName type projects as System.Type. When programming using C#, it is common to use the typeof operator to get references to the System.Type of a type. In Visual Basic, use GetType. If you're using C++/CX), where you'll need to create a TypeName helper struct, you can use the typeid component extension.

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;
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

DependencyProperty
Custom dependency properties
Dependency properties overview

 

 

Show:
© 2014 Microsoft