共用方式為


ContextAttributes 介面

包含與 [動態說明] 視窗中之全域內容或視窗內容關聯的所有屬性。

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

語法

'宣告
<GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")> _
Public Interface ContextAttributes _
    Inherits IEnumerable
[GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")]
public interface ContextAttributes : IEnumerable
[GuidAttribute(L"33C5EBB8-244E-449D-9CEE-FAD70A774E59")]
public interface class ContextAttributes : IEnumerable
[<GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")>]
type ContextAttributes =  
    interface
        interface IEnumerable
    end
public interface ContextAttributes extends IEnumerable

ContextAttributes 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Count 取得值,表示 ContextAttributes 集合中物件的數目。
公用屬性 DTE 取得最上層的擴充性物件。
公用屬性 HighPriorityAttributes 取得 High Priority 屬性集合。
公用屬性 Parent 取得 ContextAttributes 集合的直接上層父物件。
公用屬性 Type 取得常數,指出物件型別。

回頁首

方法

  名稱 說明
公用方法 Add 將屬性名稱/值組加入 ContextAttributes 集合中。
公用方法 GetEnumerator() 傳回會逐一查看集合的列舉程式。 (繼承自 IEnumerable)。
公用方法 GetEnumerator() 傳回集合中項目的列舉程式。
公用方法 Item 傳回 ContextAttribute 物件,也就是 ContextAttributes 集合中的項目。
公用方法 Refresh 重新整理這個屬性集合的內容。

回頁首

備註

用於 DTE.ContextAttributes 時,這會影響在排序主題時優先順序最低的全域內容包。

用於 Window.ContextAttributes 時,這會影響視窗的內容包。 用於工具視窗時,只有在視窗擁有焦點時,這些屬性 (Attribute) 才會生效。 用於編輯器和設計工具時,只要編輯器是最後一個作用中的 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

請參閱

參考

EnvDTE 命名空間