Share via


Providing Context for Hierarchies and Hierarchy Items

To implement context-sensitive Help, you must define the context for elements in the integrated development environment (IDE). The following scenario provides context for a hierarchy. Apply this scenario starting at the hierarchy root, and progressing through all hierarchy items.

Context for Hierarchies and Hierarchy Items

  1. Implement the GetProperty method.

  2. When the GetProperty method is called with a value of VSHPROPID_UserContext specified for the propid parameter, create a context bag. For more information, see How to: Create a Context Bag or Subcontext Bag.

  3. Add and remove context from the context bag by using the IVsUserContext and RemoveAttribute methods, respectively.

    Note

    Update the context bag as context changes in the hierarchy. To ensure that you are informed of changes in the hierarchy, see AdviseHierarchyEvents.

  4. Cache the context bag in case the context is called back at a later time.

Use the following guidelines to add attributes for a hierarchy or hierarchy item.

From

Attribute 1

Hierarchy root node

Push a Product attribute, specifying your product name.

Push Product= VS to also display Visual Studio Help in the Dynamic Help window.

Folder beneath a root node

Push an Item = folder attribute.

Hierarchy item

Push an Item attribute, specifying the file type of the hierarchy item or Item = project for the root project node.

For a list of attributes and attribute values, see Attributes in Visual Studio in the Reference section of the Visual Studio Help Integration Guide.

In Visual Studio, hierarchies and hierarchy items are displayed in Solution Explorer. Because Solution Explorer, like an editor, pushes context to the selection element identifier (SEID), its context replaces the context of the previously active editor or designer. For more information, see Context in the Selection Element Identifier.

Solution Explorer pushes the F1 keywords, vs.solutionexplorer.selection, vs.solutionexplorer, and vs.solutionexplorer.solutions, when it is active. To provide context for hierarchies and hierarchy items, push only attributes to the context bag, rather than keywords. However, include one of the "vs.solutionexplorer" keywords as a keyword for all hierarchy Help topics in the information provider. Consequently, you make your Help topics available only when Solution Explorer has focus. However, your attributes remain active after the user changes focus to the editor, designer, or another tool window. This allows the topics from those context providers to be filtered by your attributes without filling the Dynamic Help window with irrelevant topics.

Use the following guidelines to select the appropriate "vs.solutionexplorer" keyword:

Term

Definition

"vs.solutionexplorer"

Use this keyword to target topics that specifically mention Solution Explorer.

"vs.solutionexplorer.solutions"

Use this keyword to target general topics about the project or solution. These are topics that are considered to be ambient in the context of the particular project or solution. For example, Managing Visual Basic Projects and Adding References to Visual Basic Projects.

"vs.solutionexplorer.selection"

Use this keyword to target topics that relate to specific items in Solution Explorer that have focus, or for other specific topics for the project. For example, Aspx Files in a Visual Basic Web Application (if item=aspx) or Building Web Applications Using Visual Basic (if item=project).

The order of precedence in the Dynamic Help window for these keywords is as follows:

  1. "vs.solutionexplorer.selection"

  2. "vs.solutionexplorer"

  3. "vs.solutionexplorer.solutions"

Other than the "vs.solutionexplorer" keywords, it is not recommended that you push keywords from hierarchies or hierarchy items. If you push an F1 keyword for a hierarchy or hierarchy item, then this keyword can generate F1 results, even when the focus is not on Solution Explorer.

See Also

Tasks

How to: Create a Context Bag or Subcontext Bag

Concepts

Context in the Selection Element Identifier