ToolboxBrowsableAttribute 构造函数

初始化 ToolboxBrowsableAttribute 类的新实例。

命名空间:  Microsoft.Windows.Design
程序集:  Microsoft.Windows.Design.Interaction(在 Microsoft.Windows.Design.Interaction.dll 中)

语法

声明
Public Sub New ( _
    browsable As Boolean _
)
public ToolboxBrowsableAttribute(
    bool browsable
)
public:
ToolboxBrowsableAttribute(
    bool browsable
)
new : 
        browsable:bool -> ToolboxBrowsableAttribute
public function ToolboxBrowsableAttribute(
    browsable : boolean
)

参数

  • browsable
    类型:System.Boolean
    如果工具箱浏览器中的控件可见,则为 true;否则为 false。

示例

以下代码示例演示如何使用 ToolboxBrowsableAttribute 在自定义工具箱浏览器中启用自定义控件的可见性。

' 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()

            builder.AddCustomAttributes( _
                GetType(ButtonWithDesignTime), _
                New ToolboxBrowsableAttribute(True))

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

            builder.AddCustomAttributes(
                typeof(ButtonWithDesignTime),
                new ToolboxBrowsableAttribute(true));

            return builder.CreateTable();
        }
    }
}

.NET Framework 安全性

请参见

参考

ToolboxBrowsableAttribute 类

Microsoft.Windows.Design 命名空间

AttributeTableBuilder

其他资源

演练:创建设计时装饰器