AttributeTableBuilder.CreateTable 方法
更新:2007 年 11 月
创建一个属性表,其中包含通过 AddCustomAttributes 调用提供的所有属性定义。
命名空间: Microsoft.Windows.Design.Metadata
程序集: Microsoft.Windows.Design(在 Microsoft.Windows.Design.dll 中)
语法
声明
Public Function CreateTable As AttributeTable
用法
Dim instance As AttributeTableBuilder
Dim returnValue As AttributeTable
returnValue = instance.CreateTable()
public AttributeTable CreateTable()
public:
AttributeTable^ CreateTable()
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 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 命名空间