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