Export (0) Print
Expand All

DependencyProperty.DefaultMetadata Property

Gets the default metadata of the dependency property.

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

public PropertyMetadata DefaultMetadata { get; }

Property Value

Type: System.Windows.PropertyMetadata
The default metadata of the dependency property.

The default metadata is the property metadata that is available to that particular object or an object of a derived type where no alternative metadata was supplied by an explicit Register or OverrideMetadata call.

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft