title: MVVM Ribbon Application Menu Implementation (WPF 4.5 Ribbon)
body: <p>I am trying to Implement the Application Menu of a Ribbon Control in WPF 4.5 using the MVVM Pattern. Therefore I created an ApplicationMenuViewModel which contains an observable collection of AbstractApplicationMenuItemViewModel which is an abstract class used to unify the classes ...SplitItem and ...Item. The SplitItem shall be able to contain other RibbonApplicationMenuSplitItems or just plain RibbonApplicationMenuItems to an arbitrary level of hierarchy. Therefore it contains itself an ObservableCollection which may contain ...SplitItems or plain ...Items. 
  The ApplicationMenu itself is provided through a Factory Class due to other Architectural Reasons. The problem I am experiencing now is that nothing is shown in the ApplicationMenu at all. The ViewModel is instantiated correctly so I think that the problem is mainly due to my abstraction of the two different items that may be contained inside ApplicationMenuSplitItemViewModel and ApplicationMenuViewModel. 
  So the question is what is the most flexible, maintainable and easy way to implement the templating and/or styling to get the RibbonApplicationMenu to show up?
  At the moment the following template is applied:</p>
  
  <pre><code>&lt;!--Ribbon Application Menu Styling and Templating--&gt;
  &lt;DataTemplate DataType="{x:Type rvmmnu:ApplicationMenuViewModel}"&gt;
      &lt;RibbonApplicationMenu ItemsSource="{Binding Children}"/&gt;
  &lt;/DataTemplate&gt;
  
  &lt;DataTemplate DataType="{x:Type rvmmnu:ApplicationMenuItemViewModel}"&gt;
      &lt;RibbonApplicationMenuItem Header="{Binding DisplayName}" 
                                 ImageSource="{Binding ImageSource}" 
                                 Command="{Binding Command}"/&gt;
  &lt;/DataTemplate&gt;
  
  &lt;DataTemplate DataType="{x:Type rvmmnu:ApplicationMenuSplitItemViewModel}"&gt;
      &lt;RibbonApplicationSplitMenuItem ItemsSource="{Binding Children}"
                                      Header="{Binding DisplayName}"/&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>The Ribbon itself is instantiated with this XAML:</p>
  
  <pre><code>    &lt;Ribbon DockPanel.Dock="Top" ItemContainerStyle="{StaticResource    ResourceKey=ribbonTabStyle}" 
              ItemsSource="{Binding Path=Ribbon.Tabs}" 
              ApplicationMenu="{Binding Path=Ribbon.ApplicationMenu}"/&gt;
  </code></pre>
  
  <p>With this configuration the Application Menu shows nothing at the moment. I suppose the problem is steming from the fact that I am abstracting away the difference between the two hierarchical items contained in the menu. I was thinking about using a custom template selector for RibbonApplicationMenu and RibbonApplicationMenuSplitItem. Another approach I was thinking about was to divide the different object types (...SplitItem and ...Item) into two different collections and use a multi binding for the ItemsSource Property. But I am not really satisfied with these approaches because I think that there is an easier way to achieve what I want.</p>