更新:2007 年 11 月
包含与“动态帮助”窗口中的全局上下文或窗口上下文关联的所有属性。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
<GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")> _
Public Interface ContextAttributes _
Implements IEnumerable
用法
Dim instance As ContextAttributes
[GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")]
public interface ContextAttributes : IEnumerable
[GuidAttribute(L"33C5EBB8-244E-449D-9CEE-FAD70A774E59")]
public interface class ContextAttributes : IEnumerable
public interface ContextAttributes extends IEnumerable
备注
对于 DTE.ContextAttributes,它会影响全局上下文包,此包在主题排序时优先级最低。
对于 Window.ContextAttributes,它会影响窗口的上下文包。对于工具窗口,只在窗口具有焦点时这些属性才有效。对于编辑器和设计器,编辑器为最后的活动 MDI 子级时,属性有效。若 HighPriorityAttributes 设为 true,则属性总是有效且优先级最高。
由于只提取对象并不会刷新集合,因此获取 ContextAttributes 集合之后,必须调用 ContextAttributes.Refresh 以确保属性集合是最新的。然而,添加和移除属性会隐式地刷新 ContextAttributes 集合,因此添加或移除操作的结果为当前结果。
示例
Sub ContextAttributesExample()
' Get a reference to Solution Explorer.
Dim SolnEx As Window = DTE.Windows.Item _
(Constants.vsWindowKindSolutionExplorer)
Dim CA As ContextAttribute
' List the current attributes associated with Solution Explorer.
ListAttr(SolnEx, CA)
' Associate a new F1 keyword with Solution Explorer.
SolnEx.ContextAttributes.Add("ANewKeyword", 900, _
vsContextAttributeType.vsContextAttributeLookupF1)
ListAttr(SolnEx, CA)
' Delete the new F1 keyword from Solution Explorer.
SolnEx.ContextAttributes.Item(3).Remove()
ListAttr(SolnEx, CA)
End Sub
Sub ListAttr(ByVal SolnEx As Object, ByVal CA As ContextAttribute)
' Support function for CATest(). Lists the current attributes
' associated with Solution Explorer.
Dim msg As String
MsgBox("Number of context attributes in Solution Explorer: " & _
SolnEx.ContextAttributes.Count)
For Each CA In SolnEx.ContextAttributes
msg = msg & CA.Name & Chr(13)
Next
MsgBox(msg)
msg = ""
End Sub