DependencyObject.DependencyObjectType Property


取得包裝此執行個體之 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

Property Value


包裝此執行個體之 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)




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

Applies to

See also