共用方式為


AttributeTableBuilder.CreateTable 方法

會建立屬性表格,其中包含透過 AddCustomAttributes 呼叫所提供的全部屬性定義。

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

語法

'宣告
Public Function CreateTable As AttributeTable
public AttributeTable CreateTable()
public:
AttributeTable^ CreateTable()
member CreateTable : unit -> AttributeTable 
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 IProvideAttributeTable. If found, designers instantiate
' this class and access its AttributeTable property automatically.
Friend Class Metadata
    Implements IProvideAttributeTable

    ' Accessed by the designer to register any design-time metadata.
    Public ReadOnly Property AttributeTable() As AttributeTable _
        Implements IProvideAttributeTable.AttributeTable
        Get
            Dim builder As New AttributeTableBuilder()

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

            Return builder.CreateTable()
        End Get
    End Property


End Class
// 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();

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

            return builder.CreateTable();
        }
    }
}

.NET Framework 安全性

請參閱

參考

AttributeTableBuilder 類別

Microsoft.Windows.Design.Metadata 命名空間

AttributeTable

AttributeCallbackBuilder