DependencyObject.DependencyObjectType 属性

定义

获取 DependencyObjectType 包装此实例的 CLR 类型的。Gets the DependencyObjectType that wraps the CLR 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

属性值

DependencyObjectType

DependencyObjectType包装此实例的 CLR 类型的。A DependencyObjectType that wraps the CLR 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)

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 而不是 CLR 类型调用更有效。For example it is more efficient to call GetMetadata(DependencyObjectType) using the DependencyObjectType rather than the CLR type. DependencyObjectType 有助于加快查找速度。DependencyObjectType facilitates faster lookup.

适用于

另请参阅