共用方式為


Window.ContextAttributes 屬性

更新:2007 年 11 月

取得 ContextAttributes 集合,它可以讓 Automation 用戶端將新屬性加入至 [動態說明] 視窗中目前選取的項目,並且為其他屬性提供內容說明。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

ReadOnly Property ContextAttributes As ContextAttributes

Dim instance As Window
Dim value As ContextAttributes

value = instance.ContextAttributes
ContextAttributes ContextAttributes { get; }
property ContextAttributes^ ContextAttributes {
    ContextAttributes^ get ();
}
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
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);
}

使用權限

請參閱

參考

Window 介面

Window 成員

EnvDTE 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例