Use MVVM in RadRibbonView
This example shows how to use a RadRibbonView control with the Model-View-ViewModel (MVVM) pattern.
1. Set up the ViewModels
In order to demonstrate how the RadRibbonView can be used in an MVVM scenario, we will setup up a small example. First, we will define a MainViewModel containing a collection of TabViewModels. Each TabViewModel will hold a collection of GroupViewModels, which will hold a collection of ButtonViewModels.
Example 1: Defining the ViewModels
2. Define the RadRibbonView
Next we will define a RadRibbonView and set the DataContext to an instance of our MainViewModel. Then we can bind its ItemsSource property to the Tabs collection and wire up the hierarchy using HierarchicalDataTemplates and a DataTemplate.
Example 3: Defining the RadRibbonView
Figure 1: MVVM RadRibbonView in the Office2016 theme
For an extended implementation, check out the Paint with MVVM example from our WPF Demos Application.
SimplifiedRibbon MVVM
Using MVVM in a SimplifiedRibbon scenario is as simple as setting the SimplifiedItemTemplate property (along with the ItemTemplate) to the corresponding DataTemplate and setting the LayoutMode property to Simplified.
Example 4: SimplifiedRibbon MVVM
Figure 2: SimplifiedRibbon MVVM in the Office2016 theme
Note, that Example 4 uses exactly the same setup as Example 3.