次の方法で共有


AttributeTableBuilder.AddCallback メソッド

指定した型のメタデータが必要になったときに呼び出されるコールバックを追加します。

名前空間:  Microsoft.Windows.Design.Metadata
アセンブリ:  Microsoft.Windows.Design.Extensibility (Microsoft.Windows.Design.Extensibility.dll 内)

構文

'宣言
Public Sub AddCallback ( _
    type As Type, _
    callback As AttributeCallback _
)
public void AddCallback(
    Type type,
    AttributeCallback callback
)
public:
void AddCallback(
    Type^ type, 
    AttributeCallback^ callback
)
member AddCallback : 
        type:Type * 
        callback:AttributeCallback -> unit 
public function AddCallback(
    type : Type, 
    callback : AttributeCallback
)

パラメーター

  • type
    型: System.Type
    メタデータ属性が追加される型。

解説

Callback では、必要に応じてメタデータを属性テーブルに追加できます。この方法は、テーブルの作成時にメタデータを追加する方法より効率的です。

大きい属性テーブルを作成する場合は、AttributeCallbackBuilder クラスと共に AddCallback メソッドを使用します。

AddCallback メソッドと AttributeTableBuilder クラスを使用して、属性テーブルを作成して設定する方法を次のコード例に示します。 次のコード例は、AttributeCallbackBuilder クラス用のより大きなコード例の一部です。

// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IProvideAttributeTable. If found, designers instantiate 
// this class and access its AttributeTable property automatically.
internal class Metadata : IProvideAttributeTable
{
    // Accessed by the designer to register any design-time metadata.
    public AttributeTable AttributeTable
    {
        get
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            // Build the attribute table by using the AttributeCallbackBuilder 
            // class. The attribute table is not populated until the designer
            // needs it, which is more efficient for large attribute tables.
            builder.AddCallback(
                typeof(Button),
                delegate(AttributeCallbackBuilder callbackBuilder)
                {
                    callbackBuilder.AddCustomAttributes(
                        new DefaultPropertyAttribute("Content"));

                    // Apply the ReadOnlyAttribute to the Background property 
                    // of the Button class.
                    callbackBuilder.AddCustomAttributes(
                        "Background",
                        new ReadOnlyAttribute(true));
                });

            return builder.CreateTable();
        }
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

AttributeTableBuilder クラス

Microsoft.Windows.Design.Metadata 名前空間

AttributeTable

AttributeCallbackBuilder