MetadataStore.AddAttributeTable 方法

更新:2007 年 11 月

将指定的表添加到当前 AppDomain 的属性存储区中。

命名空间:  Microsoft.Windows.Design.Metadata
程序集:  Microsoft.Windows.Design(在 Microsoft.Windows.Design.dll 中)

语法

声明
Public Shared Sub AddAttributeTable ( _
    table As AttributeTable _
)
用法
Dim table As AttributeTable

MetadataStore.AddAttributeTable(table)
public static void AddAttributeTable(
    AttributeTable table
)
public:
static void AddAttributeTable(
    AttributeTable^ table
)
public static function AddAttributeTable(
    table : AttributeTable
)

参数

异常

异常 条件
ArgumentNullException

table 为 nullnull 引用(在 Visual Basic 中为 Nothing)。

备注

添加了属性表后,对 TypeDescriptor 的调用便会使用新添加的表中定义的属性。可向属性存储区中添加多个表。一旦出现冲突,最新添加的表中的属性获胜。

示例

下面的代码示例演示如何创建 AttributeTable 以将装饰器提供程序与控件类相关联。有关更多信息,请参见演练:创建设计时装饰器

' 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());
    }
}

权限

另请参见

参考

MetadataStore 类

MetadataStore 成员

Microsoft.Windows.Design.Metadata 命名空间

AttributeTable

AttributeTableBuilder

其他资源

元数据存储区