ToolboxBrowsableAttribute - класс
Обновлен: Ноябрь 2007
Указывает, отображается ли элемент управления в обозревателе панели элементов конструктора.
Пространство имен: Microsoft.Windows.Design
Сборка: Microsoft.Windows.Design (в Microsoft.Windows.Design.dll)
Синтаксис
'Декларация
<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
Заметки
Используйте ToolboxBrowsableAttribute, чтобы указать, отображается ли элемент управления в диалоговом окне Choose Toolbox ItemsWindows Presentation Foundation (WPF) для Visual Studio (конструктор) или в диалоговом окне Asset Library Microsoft Blend.
Примеры
В следующем примере кода показано, как использовать ToolboxBrowsableAttribute, чтобы разрешить видимость пользовательского элемента в обозревателе панели элементов конструктора.
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());
}
}
}
Иерархия наследования
System.Object
System.Attribute
Microsoft.Windows.Design.ToolboxBrowsableAttribute
Потокобезопасность
Любые открытые члены этого типа, объявленные как static (Shared в Visual Basic), являются потокобезопасными. Потокобезопасность членов экземпляров не гарантируется.
См. также
Ссылки
ToolboxBrowsableAttribute - члены
Microsoft.Windows.Design - пространство имен
Другие ресурсы
Пошаговое руководство. Создание графического элемента времени разработки