次の方法で共有


AttributeTableBuilder.CreateTable メソッド

更新 : 2007 年 11 月

AddCustomAttributes の呼び出しを通じて提供される、すべての属性定義が含まれる属性テーブルを作成します。

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

構文

'宣言
Public Function CreateTable As AttributeTable
'使用
Dim instance As AttributeTableBuilder
Dim returnValue As AttributeTable

returnValue = instance.CreateTable()
public AttributeTable CreateTable()
public:
AttributeTable^ CreateTable()
public function CreateTable() : AttributeTable

戻り値

型 : Microsoft.Windows.Design.Metadata.AttributeTable

メタデータ ストアに渡すことができる属性テーブル。

解説

テーブルは、属性ビルダの現在の状態のスナップショットです。以降の AddCustomAttributes の呼び出しは、そのテーブルに含まれません。コールバック メソッドを使用して属性を宣言した場合、それらのメソッドは CreateTable の実行中には評価されません。代わりに、これらのコールバックはテーブルに格納され、必要に応じて評価されます。

AttributeTable を作成して、メタデータ ストアに追加する方法を次のコード例に示します。Metadata クラスは、装飾プロバイダをコントロールにアタッチします。詳細については、「チュートリアル : デザイン時装飾の作成」を参照してください。

' Container for any general design-time metadata to initialize.
' Designers look for a type in the design-time assembly that 
' implements IRegisterMetadata. If found, designers instantiate 
' this class and call its Register() method automatically.
Friend Class Metadata
    Implements IRegisterMetadata

    ' Called by the designer to register any design-time metadata.
    Public Sub Register() Implements IRegisterMetadata.Register
        Dim builder As New AttributeTableBuilder()

        ' Add the adorner provider to the design-time metadata.
        builder.AddCustomAttributes(GetType(ButtonWithDesignTime), _
                                    New FeatureAttribute(GetType(OpacitySliderAdornerProvider)))

        MetadataStore.AddAttributeTable(builder.CreateTable())
    End Sub

End Class
// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IRegisterMetadata. If found, designers instantiate 
// this class and call its Register() method automatically.
internal class Metadata : IRegisterMetadata
{
    // Called by the designer to register any design-time metadata.
    public void Register()
    {
        AttributeTableBuilder builder = new AttributeTableBuilder();

        // Add the adorner provider to the design-time metadata.
        builder.AddCustomAttributes(
            typeof(ButtonWithDesignTime), 
            new FeatureAttribute(typeof(OpacitySliderAdornerProvider)));

        MetadataStore.AddAttributeTable(builder.CreateTable());
    }
}

アクセス許可

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

参照

参照

AttributeTableBuilder クラス

AttributeTableBuilder メンバ

Microsoft.Windows.Design.Metadata 名前空間

AttributeTable

AttributeCallbackBuilder

その他の技術情報

メタデータ ストア