DependencyObject.DependencyObjectType 屬性


取得 DependencyObjectType 包裝此實例之 CLR 型別的。Gets the DependencyObjectType that wraps the CLR 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



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)




如果從方法傳回的物件具有傳回值型別 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.