共用方式為


AttributeTableBuilder.AddCustomAttributes 方法 (Type, array<Attribute )

會將所提供屬性的內容加入至表格產生器。

命名空間:  Microsoft.Windows.Design.Metadata
組件:  Microsoft.Windows.Design.Extensibility (在 Microsoft.Windows.Design.Extensibility.dll 中)

語法

'宣告
Public Sub AddCustomAttributes ( _
    type As Type, _
    ParamArray attributes As Attribute() _
)
public void AddCustomAttributes(
    Type type,
    params Attribute[] attributes
)
public:
void AddCustomAttributes(
    Type^ type, 
    ... array<Attribute^>^ attributes
)
member AddCustomAttributes : 
        type:Type * 
        attributes:Attribute[] -> unit 
public function AddCustomAttributes(
    type : Type, 
    ... attributes : Attribute[]
)

參數

  • type
    型別:System.Type
    類別層級屬性要加入的目標型別。
  • attributes
    型別:array<System.Attribute[]
    要加入至 type 的新屬性。

例外狀況

例外狀況 條件
ArgumentNullException

type 或 attributes 是 nullNull 參照 (即 Visual Basic 中的 Nothing)。

備註

以「後進寫入」(Last-in-Wins) 的策略解決衝突。 當您建置大型的屬性 (Attribute) 資料表時,請使用 AddCallback 方法,以延緩建立屬性的工作直到需要建立時為止。

範例

在下列程式碼範例中,會說明如何將屬性加入至型別。 這個程式碼範例是 AttributeTableBuilder 類別完整範例的一部分。

builder.AddCustomAttributes( _
    GetType(Button), _
    New DefaultPropertyAttribute("Content"))
builder.AddCustomAttributes(
    typeof(Button),
    new DefaultPropertyAttribute("Content"));

.NET Framework 安全性

請參閱

參考

AttributeTableBuilder 類別

AddCustomAttributes 多載

Microsoft.Windows.Design.Metadata 命名空間

AttributeTable

AttributeCallbackBuilder