IRegisterMetadata 接口

更新:2007 年 11 月

指定请求将额外的属性添加到元数据存储区中的类。

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

语法

声明
Public Interface IRegisterMetadata
用法
Dim instance As IRegisterMetadata
public interface IRegisterMetadata
public interface class IRegisterMetadata
public interface IRegisterMetadata

备注

实现 IRegisterMetadata 接口可以为定义 Windows Presentation Foundation (WPF) 控件的设计时行为和外观提供自定义属性。每个设计时元数据程序集都必须包括一个实现 IRegisterMetadata 的类型。

示例

下面的代码示例演示如何实现 IRegisterMetadata 接口。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());
    }
}

另请参见

参考

IRegisterMetadata 成员

Microsoft.Windows.Design.Metadata 命名空间

MetadataStore

其他资源

元数据存储区