共用方式為


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

其他資源

中繼資料存放區