DependencyProperty.DefaultMetadata 属性

定义

获取依赖项对象的默认元数据。Gets the default metadata of the dependency property.

public:
 property System::Windows::PropertyMetadata ^ DefaultMetadata { System::Windows::PropertyMetadata ^ get(); };
public System.Windows.PropertyMetadata DefaultMetadata { get; }
member this.DefaultMetadata : System.Windows.PropertyMetadata
Public ReadOnly Property DefaultMetadata As PropertyMetadata

属性值

依赖项对象的默认元数据。The default metadata of the dependency property.

示例

pm = dp.GetMetadata(dp.OwnerType);
pm = dp.GetMetadata(dp.OwnerType)
PropertyMetadata pmDefault = dp.DefaultMetadata;
Dim pmDefault As PropertyMetadata = dp.DefaultMetadata

注解

默认元数据是可用于该特定对象的属性元数据或派生类型的对象,在该对象中,无备用元数据是由显式 RegisterOverrideMetadata 调用提供的。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.

如果原始所有者对建立了依赖属性的第一个 Register 调用应用了元数据,则此元数据将返回为 DefaultMetadataIf the original owner applied metadata to the first Register call that established the dependency property, then that metadata is returned as DefaultMetadata.

如果未在原始 Register 调用中应用元数据,则将从 Register 调用中生成默认元数据,并将该值作为 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.

使默认元数据与 DependencyProperty 关联的主要目的是为任何 DependencyObject 或派生类型上的此属性提供默认值。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.

对于非附加属性,该属性返回的元数据类型不能转换为 PropertyMetadata 类型的派生类型,即使该属性最初是使用派生的元数据类型注册的。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. 如果希望最初注册的元数据(包括其最初可能派生的元数据类型),请改为调用 GetMetadata(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.

对于附加属性,此属性返回的元数据的类型将与原始 RegisterAttached 注册方法中给定的类型匹配。For attached properties, the type of the metadata returned by this property will match the type given in the original RegisterAttached registration method.

适用于