Command Button in View.OtherWindows doesn't respect VisibilityConstraint #121
Replies: 5 comments 3 replies
-
Looks like perhaps the code for the As I understand it, the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. Here is the VisibilityConstraint, for completeness, somehow I don't seem to be able to edit this in the original post: I guess using the BeforeQueryStatus would be an option, but I tried to use the simple approach with the VisibilityConstraint. I does work for other commands (and will toggle the visibility correctly based on the context), even after the package is fully loaded, so it seems strange that it doesn't work for the view menu entry. I'd still be interested to know why my original approach doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Right. Override the InitializeAzync method and set Supported = false on the Command object after calling await base.InitializeAzync. Sorry, on my phone so I didn't check this |
Beta Was this translation helpful? Give feedback.
-
Maybe this could be added as an optional parameter in the command's InitializeAsync method, so no subclassing etc is required? Being optional, it wouldn't affect anyone's existing code, and those developers who don't need it will never need to see it. |
Beta Was this translation helpful? Give feedback.
-
@StevenRasmussen nice catch on Mads talking about it in that video, I was watching at the time it was streamed, but It didn't register in my mind at all. |
Beta Was this translation helpful? Give feedback.
-
Hi all
I'm working on an extension that provides several tool windows with their respective commands. I have set the commands to open the tool windows as DynamicVisibility and DefaultInvisible and provided a VisibilityConstraints with a context the hide/show those commands.
I found that this only works as long as I don't Initialize the command in my Package class. When I add the InitializeAsync command, the commands are always shown in the View.OtherWindows menu.
Strangely the same concept works for another set of commands with the same VisibilityConstraints that are added to the context menu in the solution explorer.
So my question is, if there is something specific to the commands that are added to the view menu, which causes the VisibilityConstraints to not work.
This is how my definition of the cmd looks in the VSCommandTable.vsct:
Beta Was this translation helpful? Give feedback.
All reactions