DependencyProperty.OwnerType 属性

定义

获取使用属性系统注册依赖属性或者将自己作为属性所有者添加的对象的类型。Gets the type of the object that registered the dependency property with the property system, or added itself as owner of the property.

public:
 property Type ^ OwnerType { Type ^ get(); };
public Type OwnerType { get; }
member this.OwnerType : Type
Public ReadOnly Property OwnerType As Type

属性值

注册属性或者将自己作为属性所有者添加的对象的类型。The type of the object that registered the property or added itself as owner of the property.

示例

下面的示例基于依赖项属性标识符 dp获取所有者类型,然后获取此同一标识符的所有者类型的元数据。The following example gets the owner type based on a dependency property identifier dp, and then gets metadata on the owner type for that same identifier. 此操作实际上等效于获取 dp上的 DefaultMetadataThis operation is actually equivalent to getting DefaultMetadata on dp.

pm = dp.GetMetadata(dp.OwnerType);
pm = dp.GetMetadata(dp.OwnerType)

注解

此值是在属性注册过程中提供的。This value was provided during property registration. 如果 DependencyPropertyRegister 调用生成的标识符,所有者将为原始注册类型,或者在 AddOwner 调用生成的 DependencyProperty 标识符的情况下将其添加为所有者的类型。The owner will be either the original registering type in the case of a DependencyProperty identifier generated from a Register call, or the type that added itself as owner in the case of a DependencyProperty identifier generated from an AddOwner call.

任何给定 DependencyProperty 上的 OwnerType 都是不可变的,并且不能在有效的 DependencyPropertynullThe OwnerType on any given DependencyProperty is immutable, and cannot be null in a valid DependencyProperty.

适用于