DependsOnAttribute 類別

定義

表示屬性化屬性與另一個屬性的值相依。

public ref class DependsOnAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true)]
public sealed class DependsOnAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true)>]
type DependsOnAttribute = class
    inherit Attribute
Public NotInheritable Class DependsOnAttribute
Inherits Attribute
繼承
DependsOnAttribute
屬性

備註

上的 SaveXamlWriter 方法會先處理指定的屬性,再處理此屬性設定所在的屬性。

name套用至此屬性的值必須是存在於相同類型之屬性的簡單不限定名稱。 您無法將附加屬性指定為相依性。

套用此屬性時,請務必小心以避免迴圈相依性。 只有在已寫入迴圈中的所有屬性時,才會偵測迴圈相依性,即使行為不具決定性亦然。

將此屬性套用至屬性定義可確保先在 XAML 物件寫入中處理相依屬性。 它是 XAML 標記的一般規則的一部分,針對所建立物件套用的屬性值應該能夠依任何順序處理。 的使用方式 DependsOnAttribute 會指定類型上的例外狀況,其中必須遵循特定剖析順序才能建立有效的物件。

在舊版的 .NET Framework 中,這個類別存在於 WPF 特定的元件 WindowsBase 中。 在 .NET Framework 4 中,DependsOnAttribute位於 System.Xaml 元件中。 如需詳細資訊,請參閱 Types Migrated from WPF to System.Xaml

WPF 使用注意事項

類別 Value 上的 Setter 屬性是 WPF DependsOnAttribute 中套用屬性的屬性範例。 Value 相依於 PropertyTargetName 先處理,否則無法知道應該針對值轉換器案例建立何種類型。

建構函式

DependsOnAttribute(String)

初始化 DependsOnAttribute 類別的新執行個體。

屬性

Name

取得這個 DependsOnAttribute 中所宣告之相關屬性的名稱。

TypeId

取得這個 DependsOnAttribute 的唯一識別項。

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。

(繼承來源 Attribute)
GetHashCode()

傳回這個執行個體的雜湊碼。

(繼承來源 Attribute)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於

另請參閱