ToolboxBrowsableAttribute Class

Specifies whether a control is visible in a designer's toolbox browser.

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

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class ToolboxBrowsableAttribute _
    Inherits Attribute
'Usage
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

Remarks

Use the ToolboxBrowsableAttribute to specify when a control is visible in the Choose Toolbox Items dialog box for the Windows Presentation Foundation (WPF) Designer for Visual Studio or the Asset Library for Microsoft Blend.

Examples

The following code example shows how to use the ToolboxBrowsableAttribute to enable visibility for a custom control in a designer's toolbox browser.

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

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.Windows.Design.ToolboxBrowsableAttribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ToolboxBrowsableAttribute Members

Microsoft.Windows.Design Namespace

AttributeTableBuilder

Other Resources

Walkthrough: Creating a Design-time Adorner