title: Command binding to top-level MenuItem of Menu doesn't work
body: <p>I'm learning WPF and developing a dynamic Menu which is driven by data binding of it's ItemsSource to an <code>ObservableCollection</code>. To do this I have a simple <code>MenuItemViewModel</code> and a <code>HierarchicalDataTemplate</code> for automatic binding of MenuItems to it.</p>
  
  <p>The problem I have is that <code>Command</code> property doesn't work for top level menu items. Despite it is set, a MenuItem doesn't react on mouse click and doesn't get disabled if Command cannot be executed. Simply it's like it's not getting bound.</p>
  
  <p>For lower level menu items though, it works as intended. I think this should be a problem of my <code>HierarchicalDataTemplate</code> but I can't find it, because as I see there's no code in template which might affect command binding of only top-level MenuItems.</p>
  
  <p><code>MenuItemViewModel</code> implements <code>INotifyPropertyChanged</code> and contains following public properties:</p>
  
  <pre><code>string Text
  Uri ImageSource
  ICommand Command
  ObservableCollection&lt;MenuItemViewModel&gt; Children
  </code></pre>
  
  <p><code>HierarchicalDataTemplate</code> for MenuItem in my <code>Window.Resources</code> is as follows:</p>
  
  <pre><code>&lt;HierarchicalDataTemplate DataType="{x:Type common:MenuItemViewModel}"
                            ItemsSource="{Binding Path=Children}"&gt;
  
      &lt;HierarchicalDataTemplate.ItemContainerStyle&gt;
          &lt;Style TargetType="MenuItem"&gt;
              &lt;Setter Property="Command"
                  Value="{Binding Command}" /&gt;
          &lt;/Style&gt;
      &lt;/HierarchicalDataTemplate.ItemContainerStyle&gt;
  
      &lt;StackPanel Orientation="Horizontal"&gt;
          &lt;Image Source="{Binding ImageSource}" /&gt;
          &lt;TextBlock Text="{Binding Text}" VerticalAlignment="Center"/&gt;
      &lt;/StackPanel&gt;
  
  &lt;/HierarchicalDataTemplate&gt;
  </code></pre>
  
  <p>Can you please point me on my mistake?</p>
  
  <p>EDIT: Top-level MenuItem doesn't contain any children (i.e. <code>Children</code> collection of associated ViewModel is empty).</p>