Método AttributeTableBuilder.AddCallback

Adiciona um retorno de chamada é invocado quando os metadados para o tipo especificado é necessária.

Namespace:  Microsoft.Windows.Design.Metadata
Assembly:  Microsoft.Windows.Design.Extensibility (em Microsoft.Windows.Design.Extensibility.dll)

Sintaxe

'Declaração
Public Sub AddCallback ( _
    type As Type, _
    callback As AttributeCallback _
)
public void AddCallback(
    Type type,
    AttributeCallback callback
)
public:
void AddCallback(
    Type^ type, 
    AttributeCallback^ callback
)
member AddCallback : 
        type:Type * 
        callback:AttributeCallback -> unit 
public function AddCallback(
    type : Type, 
    callback : AttributeCallback
)

Parâmetros

  • type
    Tipo: System.Type
    O tipo para adicionar atributos de metadados.

Comentários

Callbackpode adicionar metadados para a tabela de atributos sob demanda, o que é mais eficiente do que a adição de metadados quando a tabela é criada.

Use o AddCallback método com o AttributeCallbackBuilder classe quando você está criando uma tabela grande atributo.

Exemplos

O exemplo de código a seguir mostra como usar o AddCallback método e a AttributeTableBuilder classe para criar e preencher uma tabela de atributo. This code example is part of a larger example provided for the AttributeCallbackBuilder 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();

            // Build the attribute table by using the AttributeCallbackBuilder 
            // class. The attribute table is not populated until the designer
            // needs it, which is more efficient for large attribute tables.
            builder.AddCallback(
                typeof(Button),
                delegate(AttributeCallbackBuilder callbackBuilder)
                {
                    callbackBuilder.AddCustomAttributes(
                        new DefaultPropertyAttribute("Content"));

                    // Apply the ReadOnlyAttribute to the Background property 
                    // of the Button class.
                    callbackBuilder.AddCustomAttributes(
                        "Background",
                        new ReadOnlyAttribute(true));
                });

            return builder.CreateTable();
        }
    }
}

Segurança do .NET Framework

Consulte também

Referência

AttributeTableBuilder Classe

Namespace Microsoft.Windows.Design.Metadata

AttributeTable

AttributeCallbackBuilder