IRegisterMetadata, interface

Mise à jour : novembre 2007

Spécifie une classe qui demande des attributs supplémentaires à ajouter au magasin de métadonnées.

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

Syntaxe

Public Interface IRegisterMetadata

Dim instance As IRegisterMetadata
public interface IRegisterMetadata
public interface class IRegisterMetadata
public interface IRegisterMetadata

Notes

Implémentez l'interface IRegisterMetadata pour fournir des attributs personnalisés afin de définir le comportement et l'apparence des contrôles Windows Presentation Foundation (WPF) au moment du design. Chaque assembly de métadonnées au moment du design doit inclure un type qui implémente IRegisterMetadata.

Exemples

L'exemple de code suivant montre comment implémenter l'interface IRegisterMetadata. La classe Metadata attache un fournisseur d'ornements à un 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());
    }
}

Voir aussi

Référence

Membres IRegisterMetadata

Microsoft.Windows.Design.Metadata, espace de noms

MetadataStore

Autres ressources

Magasin de métadonnées