为属性浏览器支持。

当您在中选择 Visual Studio对象时,该对象的公共属性显示在 属性 窗口。 若要选择对象程序模型,请向可选和选定的对象列表中的对象在选择容器中的。 使用 STrackSelection 服务通知用户所选择的 Visual Studio 。

可有多列表中选定的对象,因此,只有其中处于活动状态。 Visual Studio 在 属性 窗口中选择该选项列表显示基于有焦点和其他因素的窗口。 有关更多信息,请参见 演练:显示属性设置为 " 属性 " 窗口

管理系统为 " 属性 " 窗口中支持

托管包框架 (MPF)和互操作支持创建选择容器提供,列表和从托管代码中引用服务。

MPF 提供 SelectionContainer 类创建选择容器。 选择容器包含两个集合属性、 SelectableObjectsSelectedObjects。 通过实现 ISelectionContainer来创建选择容器。

添加数组到 SelectableObjectsSelectedObjects的对象。

获取 STrackSelection 服务的一 ITrackSelection 接口,然后调用 OnSelectChange 通知用户所选择的 Visual Studio 。 将对象的公共属性显示在 属性 窗口,在调用 OnSelectChange之后。

备注

若要处理在 属性 窗口或对象公开的属性,请首先调用与 null 选择容器的 OnSelectChange 。在处理属性或对象之后,可以更改更新了 SelectableObjects ,并 SelectedObjects 列表中选择容器。

属性和布局

CategoryAttributeDisplayNameAttributeDescriptionAttribute 特性确定属性的布局,标记和说明在 属性 窗口中。 这些属性确定该选项类别、显示名称和说明,分别。

备注

等效属性、 SRCategory、 LocDisplayName 和 SRDescription,使用本地化的字符串资源并在中定义 managed project sample

请考虑下面的代码片段。

Private m_someText As String = ""

<Category("My Properties")> _
<Description("Simple Properties")> _
<DisplayName("MyText")> _
Public Property SomeText() As String 
    Get 
        Return m_someText
    End Get 
    Set(ByVal value As String)
        m_someText = value
    End Set 
End Property
private string someText = "";

[Category("My Properties")]
[Description("Simple Properties")]
[DisplayName("MyText")]
public string SomeText
{
    get { return someText; }
    set { someText = value; }
}

SomeText 属性会出现在 属性 窗口作为类别中的 MyText我的属性。 如果属性时,该声明, 简单属性,显示。

请参见

参考

“属性”窗口

其他资源

VSPackage 状态