DependencyObject.DependencyObjectType 屬性

定義

取得包裝此執行個體之 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. 例如,使用 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.

適用於

另請參閱