VisibilityItem Element

The VisibilityItem element determines the static visibility of commands and toolbars. Every entry identifies a command or menu, and also an associated command UI context. Visual Studio detects commands, menus, and toolbars, and their visibility, without loading the VSPackages that define them. The IDE uses the IsCmdUIContextActive method to determine whether a command UI context is active.

After the VSPackage is loaded, Visual Studio expects command visibility to be determined by the VSPackage rather than the VisibilityItem. To determine your command's visibility, you can implement either the BeforeQueryStatus event handler or the QueryStatus method, depending on how you have implemented your command.

A command or menu that has a VisibilityItem element appears only when the associated context is active. You can associate a single command, menu, or toolbar with one or more command UI contexts by including an entry for each command-context combination. If a command or menu is associated with multiple command UI contexts, then the command or menu is visible when any one of the associated command UI contexts is active.

The VisibilityItem element applies only to commands, menus, and toolbars, not to groups. An element that does not have a related VisibilityItem element is visible whenever its parent menu is active.

<VisibilityItem
  guid ="="cmdGuidMyProductCommands"
  id=="cmdidAddWidget"
  context="guidNotViewSourceMode"/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

guid

Required. The GUID of the GUID/ID command identifier.

id

Required. The ID of the GUID/ID command identifier.

context

Required. The UI context in which the command is visible.

Condition

Optional. See VSCT XML Schema Conditional Attributes.

Child Elements

None

Parent Elements

Element

Description

VisibilityConstraints Element

The VisibilityConstraints element determines the static visibility of groups of commands and toolbars.

Remarks

The standard Visual Studio UI contexts are defined in the Visual Studio SDK installation path\VisualStudioIntegration\Common\Inc\vsshlids.h file as well as in the UIContextGuids and UIContextGuids80 classes. A more complete set of UI contexts is defined in the VSConstants class.

Example

<VisibilityConstraints>
  <VisibilityItem guid="cmdSetGuidMyProductCommands"     id="cmdidAddWidget"
    context="guidNotViewSourceMode"/>
</VisibilityConstraints>

See Also

Reference

VisibilityConstraints Element

IsCmdUIContextActive

BeforeQueryStatus

VSConstants

UIContextGuids

UIContextGuids80

Other Resources

Visual Studio Command Table (.Vsct) Files