Change text/visibility of a command/button #505
-
Hi, I need to change visibility / change the text of a button/menu command in runtime. I've found this piece of documentation: https://learn.microsoft.com/en-us/visualstudio/extensibility/changing-the-appearance-of-a-command?view=vs-2022 However, I wonder if community toolkit makes this process less painful than the official examples. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@pbanosdev There is some sample code in the docs here: https://learn.microsoft.com/en-us/visualstudio/extensibility/changing-the-text-of-a-menu-command?view=vs-2022 |
Beta Was this translation helpful? Give feedback.
-
In your Command class that inherits from BaseCommand, you should have access to the Command property: With this you should be able to change the text and visibility. |
Beta Was this translation helpful? Give feedback.
In your Command class that inherits from BaseCommand, you should have access to the Command property:
Community.VisualStudio.Toolkit/src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands/BaseCommand.cs
Line 100 in 2fac3c4
With this you should be able to change the text and visibility.