IRegisterMetadata.Register 方法
更新:2007 年 11 月
将设计时元数据附加到特定的控件类型。
命名空间: Microsoft.Windows.Design.Metadata
程序集: Microsoft.Windows.Design(在 Microsoft.Windows.Design.dll 中)
语法
声明
Sub Register
用法
Dim instance As IRegisterMetadata
instance.Register()
void Register()
void Register()
function Register()
备注
Register 方法在设计器初始化期间调用。
实现 Register 方法的类应使用 AddAttributeTable 方法向存储区中添加元数据。
示例
下面的代码示例演示如何实现 Register 方法。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());
}
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
另请参见
参考
Microsoft.Windows.Design.Metadata 命名空间