ConstructorArgumentAttribute 類別
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定可使用非無參數建構函式語法而初始化的物件,以及所指定名稱的屬性會提供建構資訊。 這項資訊主要供 XAML 序列化之用。
public ref class ConstructorArgumentAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
public sealed class ConstructorArgumentAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)>]
type ConstructorArgumentAttribute = class
inherit Attribute
Public NotInheritable Class ConstructorArgumentAttribute
Inherits Attribute
- 繼承
- 屬性
這個屬性會指定建構函式參數可以初始化相關聯的屬性,如果使用建構函式來建構實例,則應該忽略 XAML 串行化。 這可提供參數化建構函式語法的較佳來回表示法,而不是無參數建構函式具現化加上特定屬性。
架構可能支援保留標記延伸用法,並加以重新建構,而不是依賴 ProvideValue
物件樹狀結構中的輸出進行串行化。 在此情況下, ConstructorArgumentAttribute 資訊在串行化期間很有用,以產生一般標記延伸使用方式的精確表示法。 如需標記延伸的詳細資訊,請參閱 Markup Extensions for XAML Overview。
若要對 ConstructorArgumentAttribute 屬性有效,類型的公用非無參數建構函式必須只支援一個參數。 參數的名稱必須對應至讀取/寫入屬性。 屬性必須可串行化。 您可以使用這個屬性來建立建構函式中參數名稱與 屬性之間的對應。 具體而言,您會將這個屬性套用至連接讀取/寫入屬性的屬性層級定義。
的取用者 ConstructorArgumentAttribute 可能會在無法解析為型別支持的情況下 ArgumentName 擲回,或套用至沒有適當建構自變數和arity的類型時。
在舊版的 .NET Framework 中,這個類別存在於 WPF 特定的元件 WindowsBase 中。 在 .NET Framework 4 中,ConstructorArgumentAttribute位於 System.Xaml 元件中。 如需詳細資訊,請參閱 Types Migrated from WPF to System.Xaml。
如需標記延伸和 WPF 的詳細資訊,請參閱 標記延伸和 WPF XAML。
Argument |
取得將初始化相關聯屬性的建構函式名稱參數。 |
Type |
在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。 (繼承來源 Attribute) |
Equals(Object) |
傳回值,這個值指出此執行個體是否與指定的物件相等。 (繼承來源 Attribute) |
Get |
傳回這個執行個體的雜湊碼。 (繼承來源 Attribute) |
Get |
取得目前執行個體的 Type。 (繼承來源 Object) |
Is |
在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。 (繼承來源 Attribute) |
Match(Object) |
在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。 (繼承來源 Attribute) |
Memberwise |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
To |
傳回代表目前物件的字串。 (繼承來源 Object) |
_Attribute. |
將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。 (繼承來源 Attribute) |
_Attribute. |
擷取物件的類型資訊,可以用來取得介面的類型資訊。 (繼承來源 Attribute) |
_Attribute. |
擷取物件提供的類型資訊介面數目 (0 或 1)。 (繼承來源 Attribute) |
_Attribute. |
提供物件所公開的屬性和方法的存取權。 (繼承來源 Attribute) |
產品 | 版本 |
---|---|
.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, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |