DependencyObject.DependencyObjectType 属性

定义

获取对此实例的 CLRCLR 类型进行包装的 DependencyObjectTypeGets the DependencyObjectType that wraps the CLRCLR type of this instance.

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

属性值

对此实例的 CLRCLR 类型进行包装的 DependencyObjectTypeA DependencyObjectType that wraps the CLRCLR type of this instance.

示例

在下面的伪代码示例中,MySubClass 预计其他派生类可能更改 @no__t 依赖属性的默认值。In the following pseudocode example, MySubClass anticipates that additional derived classes might change the default value of the MyCustom dependency property. 类实现了一个无参数的构造函数,该构造函数可以通过在 DependencyObjectType 值上利用多态性,只要该构造函数用作 instantiator 派生类。The class implements a parameterless constructor that can determine the actual derived class by taking advantage of polymorphism on the DependencyObjectType value whenever that constructor is used as a derived class instantiator.

public DOClass() : base()

{

__customPropertyCache = (CustomDP)

CustomDPProperty.GetMetadata(DependencyObjectType).DefaultValue;

}

注解

如果从方法返回的对象的返回值类型为 DependencyObject,并且你想要根据其类型对其执行特定于属性系统的操作,则此属性很有用。This property is useful if an object that is returned from a method has a return value type of DependencyObject and you want to perform property system specific operations on it depending on its type. 例如,使用 DependencyObjectType 而不是 CLRCLR 类型调用 GetMetadata(DependencyObjectType) 更有效。For example it is more efficient to call GetMetadata(DependencyObjectType) using the DependencyObjectType rather than the CLRCLR type. DependencyObjectType 有助于加快查找速度。DependencyObjectType facilitates faster lookup.

适用于

另请参阅