ToolboxBrowsableAttribute (Clase)
Actualización: noviembre 2007
Especifica si hay un control visible en el explorador del cuadro de herramientas del diseñador.
Espacio de nombres: Microsoft.Windows.Design
Ensamblado: Microsoft.Windows.Design (en Microsoft.Windows.Design.dll)
Sintaxis
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class ToolboxBrowsableAttribute _
Inherits Attribute
Dim instance As ToolboxBrowsableAttribute
[AttributeUsageAttribute(AttributeTargets.Class)]
public sealed class ToolboxBrowsableAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)]
public ref class ToolboxBrowsableAttribute sealed : public Attribute
public final class ToolboxBrowsableAttribute extends Attribute
Comentarios
Utilice ToolboxBrowsableAttribute para especificar cuando un control está visible en el cuadro de diálogo Elegir elementos del cuadro de herramientas de Windows Presentation Foundation (WPF) Designer for Visual Studio o el Panel biblioteca de Microsoft Blend.
Ejemplos
En el ejemplo de código siguiente se muestra cómo utilizar ToolboxBrowsableAttribute para habilitar la visibilidad de un control personalizado en el explorador del cuadro de herramientas del diseñador.
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.ComponentModel
Imports System.Windows.Media
Imports System.Windows.Controls
Imports System.Windows
Imports Microsoft.Windows.Design
Imports Microsoft.Windows.Design.Features
Imports Microsoft.Windows.Design.Metadata
Public Class ButtonWithDesignTime
Inherits Button
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.
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()
builder.AddCustomAttributes( _
GetType(ButtonWithDesignTime), _
New ToolboxBrowsableAttribute(True))
MetadataStore.AddAttributeTable(builder.CreateTable())
End Sub
End Class
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows;
using Microsoft.Windows.Design;
using Microsoft.Windows.Design.Features;
using Microsoft.Windows.Design.Metadata;
namespace CustomControlLibrary.Design
{
public class ButtonWithDesignTime : Button
{
}
// 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();
builder.AddCustomAttributes(
typeof(ButtonWithDesignTime),
new ToolboxBrowsableAttribute(true));
MetadataStore.AddAttributeTable(builder.CreateTable());
}
}
}
Jerarquía de herencia
System.Object
System.Attribute
Microsoft.Windows.Design.ToolboxBrowsableAttribute
Seguridad para subprocesos
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Vea también
Referencia
ToolboxBrowsableAttribute (Miembros)
Microsoft.Windows.Design (Espacio de nombres)