title: WPF: Hiding ContextMenu when empty
body: <p>I have a context menu that gets menu items through databinding (I'm using the MVVM pattern):</p>
  
  <pre><code>&lt;ContextMenu ItemsSource="{Binding Path=ContextMenuItems}" /&gt;
  </code></pre>
  
  <p>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?</p>
  
  <p>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...</p>