DependencyObject.DependencyObjectType 屬性

定義

取得包裝 DependencyObjectType 這個實例 CLR 型別的 。

C#
public System.Windows.DependencyObjectType DependencyObjectType { get; }

屬性值

DependencyObjectType

DependencyObjectType 包裝這個實例的 CLR 型別。

範例

在下列虛擬程式碼範例中, MySubClass 預期其他衍生類別可能會變更相依性屬性的 MyCustom 預設值。 類別會實作無參數建構函式,只要使用該建構函式做為衍生類別具現化器,就可以利用值上的 DependencyObjectType 多型來判斷實際的衍生類別。

public DOClass() : base()

{

__customPropertyCache = (CustomDP)

CustomDPProperty.GetMetadata(DependencyObjectType).DefaultValue;

}

備註

如果從方法傳回的物件具有 的 DependencyObject 傳回值型別,而且您想要根據其類型對它執行屬性系統特定作業,這個屬性就很有用。 例如,使用 DependencyObjectType 而非 CLR 類型呼叫 GetMetadata(DependencyObjectType) 會更有效率。 DependencyObjectType 有助於更快速的查閱。

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另請參閱