View navigation with Ribbon control

Topics: Prism v4 - WPF 4
Oct 17, 2011 at 6:35 PM


I am creating an application which looks like access

Which is based on David Veeneman Sample

On the left side there is a list with queries, reports forms etc..

And on the right a view (different one for each type of object) to manage them

Every Tab in the ribbon is also a view

1. I am not sure what is the correct way for managing view models with the ribbon

2. In some scenario a group in the a single Ribbon tab can be bound to two View Model (the left side View Model and the Main View Model)

3. I am not sure how do I connect the Ribbon to the active View Model

Currently I am registering the module with unity as a singleton In order to share it between the Ribbon and the Main View

 Thanks in advance

Oct 18, 2011 at 6:17 PM
Edited Oct 18, 2011 at 6:19 PM


Since your views usually inherit from the FrameworkElement class, which contains a DataContext property, that allows you to match a view to it's corresponding view model. It's possible to bind to the properties and commands exposed by the view model from inside the view.

An example of this can be seen in the ModuleATaskButton define in David Veeneman Sample:


public partial class ModuleATaskButton : UserControl
        public ModuleATaskButton(ModuleATaskButtonViewModel viewModel)
            this.DataContext = viewModel;

You might find more information regarding that in the following links:


Also note that the application Ribbon is defined as a Prism region, so that modules can load their own tabs (views) into the Ribbon (this is possible because there is a RibbonRegionAdapter).

You can read more about Prism regions (which are the main element of Prism's UI Composition mechanisms) in the following chapter from the Prism MSDN documentation:

I hope you find this useful.

Agustin Adami