View and ViewModel are in same assembly but getting "Cannot find View for ViewModel" error

Topics: Getting Started
Oct 20, 2013 at 9:20 AM
I am following right naming convention to name views and viewModels.

I have 2 assemblies. One has ShellView and associated ShellViewModel.

Assembly Name: RBC.FX.StartUp

RBC.FX.StartUp.ShellView
RBC.FX.StartUp.ShellViewModel



The other assembly has RatesView and RatesViewModel.

Assembly Name: RBC.FX.RatesManager

RBC.FX.RatesManager.RatesView
RBC.FX.RatesManager.RatesViewModel


I am trying to display the RatesView on the ShellView.

ShellView is a window and RatesView is UserControl.

ShellView is loading but I couldn't display the RatesView on ShellView as I am getting the following error message --"Cannot find View for ViwModel"
<Window x:Class="RBC.FX.StartUp.ShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ShellView">
    <StackPanel>
        <ContentControl x:Name="RatesMonitor"/>
    </StackPanel>
</Window>


namespace RBC.FX.StartUp
{
    public class ShellViewModel
    {
        public ShellViewModel()
        {
            RatesMonitor = new RatesViewModel();
        }

        public RatesViewModel RatesMonitor { get; set; }
    }
}

<UserControl x:Class="RBC.FX.RatesManager.RatesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Border BorderBrush="Blue" CornerRadius="25" BorderThickness="10" Width="500" Height="100" >
        <TextBlock Text="Rates" VerticalAlignment="Center" HorizontalAlignment="Center"/>
    </Border>
</UserControl>

namespace RBC.FX.RatesManager
{
    public class RatesViewModel
    {
    }
}

namespace RBC.FX.StartUp
{
    public class FxBootstrapper : Bootstrapper<ShellViewModel>
    {
    }
}

<Application x:Class="RBC.FX.StartUp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:local="clr-namespace:RBC.FX.StartUp">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <local:FxBootstrapper x:Key="bootstrapper" />
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </Application.Resources>
</Application>
I am using the Caliburn.Micro 1.5.2. Please suggest any idea where I am making mistake.
Oct 20, 2013 at 9:26 AM
Your bootstrapper has to override SelectAssemblies() to return both assemblies.
Marked as answer by tibel on 10/21/2013 at 10:07 PM
Oct 20, 2013 at 9:56 AM
Thanks. Now It works fine.....