Window2.ContextAttributes 属性
获取 ContextAttributes 集合,该集合允许自动化客户端向**“动态帮助”**窗口中的当前选定项添加新特性,并为其他特性提供上下文帮助。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
ReadOnly Property ContextAttributes As ContextAttributes
Get
ContextAttributes ContextAttributes { get; }
property ContextAttributes^ ContextAttributes {
ContextAttributes^ get ();
}
abstract ContextAttributes : ContextAttributes
function get ContextAttributes () : ContextAttributes
属性值
类型:EnvDTE.ContextAttributes
一个 ContextAttributes 集合。
实现
示例
此示例列出**“解决方案资源管理器”**的上下文特性。
有关如何作为外接程序运行此示例的更多信息,请参见如何:编译和运行自动化对象模型代码示例。
Sub ContextAttributesExample(ByVal dte As DTE2)
' List the current context attributes associated with
' Solution Explorer.
Dim explorerWin As Window = dte.ToolWindows.SolutionExplorer.Parent
Dim attrs As String
Dim attr As ContextAttribute
For Each attr In explorerWin.ContextAttributes
attrs &= attr.Name & vbCrLf
Next
MsgBox("Solution Explorer has the following context attributes:" _
& vbCrLf & vbCrLf & attrs)
' Associate a new F1 keyword with Solution Explorer.
explorerWin.ContextAttributes.Add("ANewKeyword", "900", _
vsContextAttributeType.vsContextAttributeLookupF1)
attrs = ""
For Each attr In explorerWin.ContextAttributes
attrs &= attr.Name & vbCrLf
Next
MsgBox("Solution Explorer has the following context attributes:" _
& vbCrLf & vbCrLf & attrs)
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void ContextAttributeExample(DTE2 dte)
{
// List the current context attributes associated with
// Solution Explorer.
Window explorerWin = dte.ToolWindows.SolutionExplorer.Parent;
string attrs = "";
foreach (ContextAttribute attr in explorerWin.ContextAttributes)
attrs += attr.Name + "\n";
MessageBox.Show(
"Solution Explorer has the following context attributes:\n\n" +
attrs);
// Associate a new F1 keyword with Solution Explorer.
explorerWin.ContextAttributes.Add("ANewKeyword", "900",
vsContextAttributeType.vsContextAttributeLookupF1);
attrs = "";
foreach (ContextAttribute attr in explorerWin.ContextAttributes)
attrs += attr.Name + "\n";
MessageBox.Show(
"Solution Explorer has the following context attributes:\n\n" +
attrs);
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。