DependencyObject.DependencyObjectType 属性


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

 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 预计其他派生类可能会更改依赖属性的默认值 MyCustomIn 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)




如果从方法返回的对象的返回值类型为 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. 例如, GetMetadata(DependencyObjectType) 使用 DependencyObjectType 而不是类型来调用更有效 CLRCLRFor example it is more efficient to call GetMetadata(DependencyObjectType) using the DependencyObjectType rather than the CLRCLR type. DependencyObjectType 有助于加快查找速度。DependencyObjectType facilitates faster lookup.