Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show\hide Commands conditionally in Visual Studio Extension

I am creating a Visual Studio Extension, which should perform following activities:

  1. On Right Click of Project, should show a Command.
  2. Specific command should be shown for specific project.

For Example: enter image description here

I have added a Commands Menu where there are 2 Commands. But I want to show only 'Command for Proj ABC' when right clicked on ABC project and similarly 'Command for Proj XYZ' should be shown when right clicked on XYZ project.

Is this possible? How Can I achieve this?

like image 931
EnigmaticJohn Avatar asked Jan 30 '26 16:01

EnigmaticJohn


1 Answers

You need to add DynamicVisibility CommandFlag in .vsct for your commands and set Visible status in your OnBeforeQueryStatus handler depending on which project is currently selected.

See Change the text of a menu command for an example.

like image 67
Sergey Vlasov Avatar answered Feb 02 '26 09:02

Sergey Vlasov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!