Condividi tramite


Classe MetadataStore

Aggiornamento: novembre 2007

Contenitore di attributi Design-Time personalizzati.

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

Sintassi

Public NotInheritable Class MetadataStore

Non è necessario dichiarare un'istanza di una classe statica per accedere ai relativi membri.
public static class MetadataStore
public ref class MetadataStore abstract sealed
public final class MetadataStore

Note

Utilizzare la classe MetadataStore per connettere attributi Design-Time a tipi. Specificare gli attributi personalizzati in un oggetto AttributeTable, creato con AttributeTableBuilder.

Aggiungere la tabella di attributi all'archivio di metadati utilizzando il metodo AddAttributeTable. Una volta aggiunti, questi attributi vengono visualizzati quando si chiamano i metodi TypeDescriptor.

Esempi

Nell'esempio di codice seguente viene illustrato come creare un oggetto AttributeTable 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
  Microsoft.Windows.Design.Metadata.MetadataStore

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 MetadataStore

Spazio dei nomi Microsoft.Windows.Design.Metadata

AttributeTable

AttributeTableBuilder

Altre risorse

Archivio di metadati