View navigation with Ribbon control

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

Hi,


I am creating an application which looks like access


Which is based on David Veeneman Sample


http://www.codeproject.com/KB/WPF/Prism4AppChecklist.aspx


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

Developer
Oct 18, 2011 at 5:17 PM
Edited Oct 18, 2011 at 5:19 PM

Hi,

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)
        {
            InitializeComponent();
            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
http://blogs.southworks.net/aadami