共用方式為


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 將設計階段功能附加至型別。

設計工具會視需要將這個屬性中定義的功能提供者具現化 (Instantiated)。如需詳細資訊,請參閱功能提供者和功能連接器

範例

在下列程式碼範例中,會說明如何建立 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

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

FeatureAttribute 成員

Microsoft.Windows.Design.Features 命名空間

FeatureProvider

其他資源

功能提供者和功能連接器