Hide ContextMenu when Menu has no items
<p>I have created a ContextMenu with a Menu inside it. The Menu doesn't always have items. When there are no items I want to hide the ContextMenu.</p>

<p>Relevant code in my style (generic.xaml)</p>

<pre><code>&lt;Grid.ContextMenu&gt;
&lt;ContextMenu Margin="10,10,0,13" Name="ContextMenu" HorizontalAlignment="Left" VerticalAlignment="Top" IsOpen="False"&gt;
&lt;Menu&gt;
    &lt;Menu.ItemsSource&gt;
        &lt;Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ChildCommands"/&gt;
    &lt;/Menu.ItemsSource&gt;
    &lt;Menu.ItemContainerStyle&gt;
        &lt;Style TargetType="{x:Type MenuItem}"&gt;
            &lt;Setter Property="MenuItem.Header" Value="{Binding Command.Text}"/&gt;
            &lt;Setter Property="MenuItem.IsEnabled" Value="False"/&gt;
        &lt;/Style&gt;
    &lt;/Menu.ItemContainerStyle&gt;
    &lt;Menu.ItemsPanel&gt;
        &lt;ItemsPanelTemplate&gt;
            &lt;VirtualizingStackPanel Orientation="Vertical"/&gt;
        &lt;/ItemsPanelTemplate&gt;
    &lt;/Menu.ItemsPanel&gt;
&lt;/Menu&gt;
&lt;/ContextMenu&gt;
&lt;/Grid.ContextMenu&gt;
</code></pre>

<p>How can I hide the ContextMenu when there are no menuitems inside it?</p>

<p>EDIT : I fixed it by changing the Menu tags to ContextMenu tags.</p>