Microsoft.Ribbon binding View/ViewModel

Topics: Getting Started, UI Architecture
Apr 17, 2012 at 8:36 AM
Edited Apr 17, 2012 at 9:04 AM

What i try to achieve is, to bind views as tabs to the Microsoft Ribbon control at the application startup.
These Tabs will be located over several Modules. 

In UI Project looks like this:

ViewModel:

public class ShellViewModel : Conductor<IView>.Collection, IShell
{
    private readonly IWindowManager windowManager;
    private IEnumerable<IRibbonTabViewModel> ribbonTabs;
    public IEnumerable<IRibbonTabViewModel> RibbonTabs
    {
        get { return ribbonTabs; }
        private set { ribbonTabs = value; }
    }

    public ShellViewModel(IWindowManager windowManager)
    {
        this.windowManager = windowManager;
    }

    public ShellViewModel(IWindowManager windowManager, IRibbonTabViewModel[] ribbonTabs)
        : this(windowManager)
    {
        RibbonTabs = ribbonTabs;
    }
    ...

 


In my View i try to bind via the x:Name attribute:

<ribbon:Ribbon x:Name="RibbonTabs">            
    <ribbon:Ribbon.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding DisplayName}" />
        </DataTemplate>
    </ribbon:Ribbon.ItemTemplate>
</ribbon:Ribbon>

My Solution Structure:

dojo.core (shared components)
dojo.knight (module assembly)
dojo.samurai (module assembly)
dojo.ui (application) 

Each module assembly has it`s own views and associated view model according with the following structure:

 

// project
+--Views
|  +--MyView
+--ViewModels 
|   +--MyViewModel
+-- Module 

An example for a view that should inserted to a RibbonTab looks like this:
ViewModel:
public class KnightRibbonTabViewModel : RibbonTabViewModel
{
    public KnightRibbonTabViewModel(IRibbonGroupViewModel[] groups)
        : base(groups)
    {
        this.DisplayName = "Knight";
    }
}
View:
<UserControl x:Class="dojo.knight.Views.KnightRibbonTabView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid> 
        <TextBlock Text="Some!" />
    </Grid>
</UserControl>

I receive this when the application is started -> http://img802.imageshack.us/img802/2905/27533606.png.
It seems like the views were not resolved automatically. Waht is the correct way to acvhieve this?
Thanks in advance
Ralf