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.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Syntax

'Declaration
Public Function CreateTable As AttributeTable
public AttributeTable CreateTable()
public:
AttributeTable^ CreateTable()
member CreateTable : unit -> AttributeTable 
public function CreateTable() : AttributeTable

Return Value

Type: Microsoft.Windows.Design.Metadata.AttributeTable
An attribute table that can be used to define design-time metadata.

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 design-time metadata. 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 IProvideAttributeTable. If found, designers instantiate
' this class and access its AttributeTable property automatically.
Friend Class Metadata
    Implements IProvideAttributeTable

    ' Accessed by the designer to register any design-time metadata.
    Public ReadOnly Property AttributeTable() As AttributeTable _
        Implements IProvideAttributeTable.AttributeTable
        Get
            Dim builder As New AttributeTableBuilder()

            ' Add the adorner provider to the design-time metadata.
            builder.AddCustomAttributes(GetType(ButtonWithDesignTime), _
                                        New FeatureAttribute(GetType(OpacitySliderAdornerProvider)))

            Return builder.CreateTable()
        End Get
    End Property


End Class
// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IProvideAttributeTable. If found, designers instantiate 
// this class and access its AttributeTable property automatically.
internal class Metadata : IProvideAttributeTable
{
    // Accessed by the designer to register any design-time metadata.
    public AttributeTable AttributeTable
    {
        get 
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            // Add the adorner provider to the design-time metadata.
            builder.AddCustomAttributes(
                typeof(ButtonWithDesignTime),
                new FeatureAttribute(typeof(OpacitySliderAdornerProvider)));

            return builder.CreateTable();
        }
    }
}

.NET Framework Security

See Also

Reference

AttributeTableBuilder Class

Microsoft.Windows.Design.Metadata Namespace

AttributeTable

AttributeCallbackBuilder