DependencyProperty.DefaultMetadata Property

Gets the default metadata of the dependency property. The default metadata is the property metadata that is available to any DependencyObject or a derived type in the event that no specific metadata was supplied by an explicit Register or OverrideMetadata call.

Namespace: System.Windows
Assembly: WindowsBase (in windowsbase.dll)
XML Namespace:

public PropertyMetadata DefaultMetadata { get; }
/** @property */
public PropertyMetadata get_DefaultMetadata ()

public function get DefaultMetadata () : PropertyMetadata

You cannot use this property in XAML.

Property Value

The default metadata of the dependency property.

If the original owner applied metadata to the first Register call that established the dependency property, then that metadata is returned as DefaultMetadata.

If no metadata was applied in the original Register call, then default metadata is generated from within the Register call and this value is returned as the DefaultMetadata.

The main purpose of having default metadata associated with a DependencyProperty is to supply a default value for this property on any DependencyObject or a derived type.

For non-attached properties, the metadata type returned by this property cannot be cast to derived types of PropertyMetadata type, even if the property was originally registered with a derived metadata type. If you want the originally registered metadata including its original possibly derived metadata type, call GetMetadata(Type) instead, passing the original registering type as a parameter.

For attached properties, the type of the metadata returned by this property will match the type given in the original RegisterAttached registration method.

    pm = dp.GetMetadata(dp.OwnerType);


    PropertyMetadata pmDefault = dp.DefaultMetadata;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions