ICommandExtension.QueryStatus Method (IMenuCommand)


Implement this to define whether your command should be visible and enabled. Set command.Visible and command.Enabled. Do not change the state of the model.

Namespace:   Microsoft.VisualStudio.Modeling.ExtensionEnablement
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

void QueryStatus(
	IMenuCommand command


Type: Microsoft.VisualStudio.Modeling.ExtensionEnablement.IMenuCommand

Set command.Visible = true if the command should appear on the menu. Set command.Enabled = true if the user can invoke the command.Set command.Text to vary the menu label.

Declare an imported property Context in order to access the diagram and model:

public IDiagramContext Context { get; set; }
public void Execute (IMenuCommand command)
  command.Enabled = command.Visible =
          .GetSelectedShapes<IClassifier>().Count() > 2;

For more information, see Define a menu command on a modeling diagram.

Return to top