AttributeTableBuilder.CreateTable, méthode

Mise à jour : novembre 2007

Crée une table d'attributs qui contient toutes les définitions d'attribut fournies par le biais d'appels AddCustomAttributes.

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

Syntaxe

Public Function CreateTable As AttributeTable

Dim instance As AttributeTableBuilder
Dim returnValue As AttributeTable

returnValue = instance.CreateTable()
public AttributeTable CreateTable()
public:
AttributeTable^ CreateTable()
public function CreateTable() : AttributeTable

Valeur de retour

Type : Microsoft.Windows.Design.Metadata.AttributeTable

Table d'attributs qui peut être passée au magasin de métadonnées.

Notes

La table est une capture instantanée de l'état actuel du générateur d'attributs. Tous les appels AddCustomAttributes suivants ne sont pas inclus dans la table. Si des méthodes de rappel ont été utilisées pour déclarer des attributs, elles ne seront pas évaluées pendant CreateTable. À la place, la table contiendra ces rappels et les évaluera si nécessaire.

Exemples

L'exemple de code suivant indique comment générer un AttributeTable et l'ajouter au magasin de métadonnées. 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());
    }
}

Autorisations

Voir aussi

Référence

AttributeTableBuilder, classe

Membres AttributeTableBuilder

Microsoft.Windows.Design.Metadata, espace de noms

AttributeTable

AttributeCallbackBuilder

Autres ressources

Magasin de métadonnées