Dela via


AttributeTableBuilder.CreateTable Method

Creates an attribute table that contains all the attribute definitions provided through AddCustomAttributes calls.

Namespace:  Microsoft.Windows.Design.Metadata
Assembly:  Microsoft.Windows.Design (in Microsoft.Windows.Design.dll)

Syntax

'Declaration
Public Function CreateTable As AttributeTable
'Usage
Dim instance As AttributeTableBuilder 
Dim returnValue As AttributeTable 

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

Return Value

Type: Microsoft.Windows.Design.Metadata.AttributeTable
An attribute table that can be passed to the metadata store.

Remarks

The table is a snapshot of the current state of the attribute builder. Any subsequent AddCustomAttributes calls are not included in the table. If callback methods were used to declare attributes, those methods will not be evaluated during CreateTable. Instead, the table will contain those callbacks and will evaluate them as needed.

Examples

The following code example shows how to build an AttributeTable and add it to the metadata store. The Metadata class attaches an adorner provider to a control. For more information, see Walkthrough: Creating a Design-time Adorner.

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

.NET Framework Security

See Also

Reference

AttributeTableBuilder Class

AttributeTableBuilder Members

Microsoft.Windows.Design.Metadata Namespace

AttributeTable

AttributeCallbackBuilder

Other Resources

Metadata Store