I created a Visual Studio Add-in that adds additional commands (four of them) to the top of Code Window context menu. I'm using permanent UI approach. Depending on the cursor position within code only one of the commands would be visible and thus selectable. Other three would be hidden.
I set supported and enabled status within QueryStatus
method that does the trick for the correct command and unsupported and invisible for the rest.
The problem
The first time add-in is installed all works well. I can only see a single command in the context menu. The rest are always hidden.
The second time I load VS IDE I detect the same commands and controls (so I don't recreate something that's already there), but now all of the commands (or better
CommandBarControl/CommandBarButton
controls) are visible. Instead of hiding 3 and showing only one I can see all four of them. The correct one is enabled and the rest of the pack is disabled/grayed out.
The question
How do I hide existing commands (or CommandBarButton
controls) on the next IDE load? I tried setting button's Visible
property to false
but then even the correct control isn't displayed.