FeatureAttribute 类
更新:2007 年 11 月
存储一个表示 FeatureProvider 类型的 Type 对象。
命名空间: Microsoft.Windows.Design.Features
程序集: Microsoft.Windows.Design.Extensibility(在 Microsoft.Windows.Design.Extensibility.dll 中)
语法
声明
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface, AllowMultiple := True)> _
Public NotInheritable Class FeatureAttribute _
Inherits Attribute
用法
Dim instance As FeatureAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = true)]
public sealed class FeatureAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, AllowMultiple = true)]
public ref class FeatureAttribute sealed : public Attribute
public final class FeatureAttribute extends Attribute
备注
使用 FeatureAttribute 将设计时功能附加至类型。
设计器按照需要实例化在此属性中定义的功能提供程序。有关更多信息,请参见功能提供程序和功能连接器。
示例
下面的代码示例演示如何创建 FeatureAttribute 以将装饰器提供程序与控件类相关联。有关更多信息,请参见演练:创建设计时装饰器。
' 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());
}
}
继承层次结构
System.Object
System.Attribute
Microsoft.Windows.Design.Features.FeatureAttribute
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
另请参见
参考
Microsoft.Windows.Design.Features 命名空间