Редагувати

Поділитися через


DependencyProperty.GetMetadata Method

Definition

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.

Overloads

GetMetadata(Type)

Returns the metadata for this dependency property as it exists on a specified existing type.

GetMetadata(DependencyObject)

Returns the metadata for this dependency property as it exists on the specified object instance.

GetMetadata(DependencyObjectType)

Returns the metadata for this dependency property as it exists on a specified 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

Parameters

forType
Type

The specific type from which to retrieve the dependency property metadata.

Returns

A property metadata object.

Examples

The following example gets metadata for a dependency property based on its type. The type is obtained by using a typeof operator.

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

Remarks

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.

Applies to

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
Public Function GetMetadata (dependencyObject As DependencyObject) As PropertyMetadata

Parameters

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.

Returns

A property metadata object.

Examples

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)

Remarks

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.

Applies to

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
Public Function GetMetadata (dependencyObjectType As DependencyObjectType) As PropertyMetadata

Parameters

dependencyObjectType
DependencyObjectType

A specific object that records the dependency object type from which the dependency property metadata is desired.

Returns

A property metadata object.

Examples

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)

Remarks

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.

Applies to