AttributeTableBuilder.AddCallback – metoda
Přidá zpětné vyvolání potřebných pro zadaný typ metadat.
Obor názvů: Microsoft.Windows.Design.Metadata
Sestavení: Microsoft.Windows.Design.Extensibility (v Microsoft.Windows.Design.Extensibility.dll)
Syntaxe
'Deklarace
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
)
Parametry
- type
Typ: System.Type
Typ přidání atributů do metadat.
- callback
Typ: Microsoft.Windows.Design.Metadata.AttributeCallback
AttributeCallback Přidává metadat do Type.
Poznámky
CallbackAtribut tabulky na požádání je efektivnější než přidání metadat při vytvoření tabulky můžete přidat metadata.
Použití AddCallback metodou s AttributeCallbackBuilder třídy při vytváření velkých atributu tabulky.
Příklady
Následující příklad kódu ukazuje, jak použít AddCallback Metoda a AttributeTableBuilder třídy Vytvoření a naplnění atributu tabulky. Příklad kódu je součástí větší příklad stanovené AttributeCallbackBuilder Třída
// 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();
}
}
}
Zabezpečení rozhraní .NET Framework
- Plná důvěra přímému volajícímu. Částečně zabezpečený kód nemůže tento člen použít. Další informace naleznete v tématu Používání knihoven z částečně důvěryhodného kódu.