FeatureAttribute, classe

Mise à jour : novembre 2007

Stocke un objet Type qui représente un type FeatureProvider.

Espace de noms :  Microsoft.Windows.Design.Features
Assembly :  Microsoft.Windows.Design.Extensibility (dans Microsoft.Windows.Design.Extensibility.dll)

Syntaxe

<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

Notes

Utilisez FeatureAttribute pour joindre une fonctionnalité à un type au moment du design.

Le fournisseur de fonctionnalités défini dans cet attribut est instancié à la demande du concepteur. Pour plus d'informations, consultez Fournisseurs de fonctionnalités et connecteurs de fonctionnalités.

Exemples

L'exemple de code suivant indique comment créer un FeatureAttribute pour associer un fournisseur d'ornements à une classe de contrôle. Pour plus d'informations, consultez Procédure pas à pas : création d'un ornement au moment du design.

' 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());
    }
}

Hiérarchie d'héritage

System.Object
  System.Attribute
    Microsoft.Windows.Design.Features.FeatureAttribute

Sécurité des threads

Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi

Référence

Membres FeatureAttribute

Microsoft.Windows.Design.Features, espace de noms

FeatureProvider

Autres ressources

Fournisseurs de fonctionnalités et connecteurs de fonctionnalités