Condividi tramite


Classe FeatureAttribute

Aggiornamento: novembre 2007

Archivia un oggetto Type che rappresenta un tipo FeatureProvider.

Spazio dei nomi:  Microsoft.Windows.Design.Features
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Sintassi

<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

Note

Utilizzare FeatureAttribute per connettere una funzionalità Design-Time a un tipo.

Del provider di funzionalità definito in questo attributo viene creata un'istanza su richiesta dalla finestra di progettazione. Per ulteriori informazioni, vedere Provider di funzionalità e connettori di funzionalità.

Esempi

Nell'esempio di codice seguente viene illustrato come creare un oggetto FeatureAttribute per associare un provider di strumenti decorativi a una classe di controlli. Per ulteriori informazioni, vedere Procedura dettagliata: creazione di uno strumento decorativo visuale in fase di progettazione.

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

Gerarchia di ereditarietà

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

Codice thread safe

Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.

Vedere anche

Riferimenti

Membri FeatureAttribute

Spazio dei nomi Microsoft.Windows.Design.Features

FeatureProvider

Altre risorse

Provider di funzionalità e connettori di funzionalità