DependencyObject.DependencyObjectType DependencyObject.DependencyObjectType DependencyObject.DependencyObjectType DependencyObject.DependencyObjectType Property

定义

获取对此实例的 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中, 预计其他派生类可能会更改MyCustom依赖属性的默认值。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. 例如, GetMetadata(DependencyObjectType) DependencyObjectType使用而不CLRCLR是类型来调用更有效。For example it is more efficient to call GetMetadata(DependencyObjectType) using the DependencyObjectType rather than the CLRCLR type. DependencyObjectType有助于加快查找速度。DependencyObjectType facilitates faster lookup.

适用于

另请参阅