I have a context menu that gets menu items through databinding (I’m using the MVVM pattern):
<ContextMenu ItemsSource="{Binding Path=ContextMenuItems}" />
This works fine. However, in the cases when there are no menu items to show, I don’t want the context menu to show up at all. Is there a way to accomplish this? Some kind of XAML trigger maybe?
I’ve tried catching the Opened event och closing the context menu when there are no children. This works but the context menu still flashes by…
Maybe bind to your menu items collections count property and use a converter to set the context menu’s visibility.