title: Binding Error on dynamic and static MenuItems in WPF Application
body: <p>in my WPF Application I create a Menu from a dynamic source (XML). I combined this with a static MenuItem, it runs fine but I get some errors on the static MenuItem. The Menu looks like this</p>
  
  <pre><code>Entity
  - dynamic menu items
  - separator
  - static menu item
  </code></pre>
  
  <blockquote>
    <p>System.Windows.Data Error: 4 : Cannot find source for binding with
    reference 'RelativeSource FindAncestor,
    AncestorType='System.Windows.Controls.ItemsControl',
    AncestorLevel='1''. BindingExpression:Path=HorizontalContentAlignment;
    DataItem=null; target element is 'MenuItem' (Name=''); target property
    is 'HorizontalContentAlignment' (type 'HorizontalAlignment')</p>
  </blockquote>
  
  <p>Same for <code>VerticalAlignment</code> and after I open the Menu, I get this error too</p>
  
  <blockquote>
    <p>System.Windows.Data Error: 40 : BindingExpression path error:
    'MenuItemName' property not found on 'object' ''ModViewModel'
    (HashCode=13278932)'. BindingExpression:Path=MenuItemName;
    DataItem='ModViewModel' (HashCode=13278932); target element is
    'MenuItem' (Name=''); target property is 'Header' (type 'Object')</p>
  </blockquote>
  
  <p>The XAML for the binding
  </p>
  
  <pre><code>&lt;MenuItem Header="_Entity"&gt;
      &lt;MenuItem.ItemsSource&gt;
          &lt;CompositeCollection&gt;
              &lt;CollectionContainer Collection="{Binding Source={StaticResource MenuItems}}" /&gt;
              &lt;Separator&gt;&lt;/Separator&gt;
              &lt;MenuItem Header="Edit Templates"/&gt;
          &lt;/CompositeCollection&gt;
      &lt;/MenuItem.ItemsSource&gt;
      &lt;MenuItem.ItemContainerStyle&gt;
          &lt;Style TargetType="MenuItem"&gt;
              &lt;Setter Property="MenuItem.Header" Value="{Binding MenuItemName}"/&gt;
              &lt;Setter Property="CommandParameter" Value="{Binding Components}"/&gt;
          &lt;/Style&gt;
       &lt;/MenuItem.ItemContainerStyle&gt;
  &lt;/MenuItem&gt;
  </code></pre>
  
  <p>Is there a way to separate the static from the dynamic MenuItem so the static MenuItem doesn't use the ItemContainerStyle? Or what causes the errors? If you need more Code, please tell me.</p>
  
  <p>EDIT:
  </p>
  
  <pre><code>public ObservableCollection&lt;Models.EntityMenuItem&gt; MenuItems
  {
      get { return _menuItem; }
      set
      {
          _menuItem = value;
          OnPropertyChanged();
      }
  }
  
  public class EntityMenuItem
  {
      public string MenuItemName { get; set; }
      public Dictionary&lt;string,bool&gt; Components { get; set; }
  }
  </code></pre>