MZ-Tools Articles Series: BUG: Setting CommandBarPopup.Visible to False doesn’t work when CommandBarPopup in context menu.

When I thought that I have fixed the bug that I explained in my last post, I found another subtle one: in VS 2010 and 2012, setting to False the Visible property of a CommandBarPopup was not honored if the CommandBarPopup was created on a context menu (for example, in the Code Window context menu), but it worked if created on a Toolbar (for example, the Standard toolbar).

This is another bug introduced in the WPF-based commandbars of VS 2010, since it works as expected in VS 2008 and before. Unfortunately I was unable to detect these two bugs back in 2009 during the VS 2010 beta since MZ-Tools 6.0 did not offer the more complete customization offered by the new MZ-Tools 7.0 version to show / hide buttons and dropdown menus. But fortunately, the workaround is as easy as adding the children CommandBarButtons before setting the Visible property to False.

I have written a small article to document it:

BUG: Setting CommandBarPopup.Visible to False doesn’t work when CommandBarPopup in context menu.
http://www.mztools.com/articles/2012/MZ2012008.aspx

And I have reported the bug to Microsoft Connect (currently awaiting to be acknowledged):

https://connect.microsoft.com/VisualStudio/feedback/details/758545/commandbarpopup-visible-false-doesnt-work-when-commandbarpopup-in-context-menu#details