Share via


ICommandExtension.QueryStatus Method

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.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.10.0.dll)

Syntax

'Declaration
Sub QueryStatus ( _
    command As IMenuCommand _
)
void QueryStatus(
    IMenuCommand command
)
void QueryStatus(
    IMenuCommand^ command
)
abstract QueryStatus : 
        command:IMenuCommand -> unit 
function QueryStatus(
    command : IMenuCommand
)

Parameters

Remarks

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

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

For more information, see How to: Define a Menu Command on a Modeling Diagram.

.NET Framework Security

See Also

Reference

ICommandExtension Interface

Microsoft.VisualStudio.Modeling.ExtensionEnablement Namespace