Reputation: 193
For some reason I am getting the Cannot find view for CaliburnPractice.ViewModel
error. I've looked at some of the answers on here for this but none of them have worked for me. I've put the view and viewmodel into separate named folders and I've already overridden the SelectedAssembly method. What is going on? See my code below.
ViewModel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;
namespace CaliburnPractice
{
public class ViewModel : PropertyChangedBase
{
}
}
App.xaml
<Application x:Class="CaliburnPractice.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CaliburnPractice"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:Bootstrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
PracticeView.xaml
<UserControl x:Class="CaliburnPractice.PracticeView"
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 Width="300" Height="300" Background="LightBlue">
</Grid>
Bootstrapper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;
using System.Reflection;
namespace CaliburnPractice
{
public class Bootstrapper : BootstrapperBase
{
public Bootstrapper()
{
Initialize();
}
protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
{
base.OnStartup(sender, e);
DisplayRootViewFor<ViewModel>();
}
protected override IEnumerable<System.Reflection.Assembly> SelectAssemblies()
{
return new[]
{
Assembly.GetExecutingAssembly()
};
}
}
}
Upvotes: 1
Views: 2454
Reputation: 3914
Because it is looking for View, where your viewmodel is named ViewModel...the view you have listed is PracticeView...
ShellView -> ShellViewModel
MainView -> MainViewModel etc....
therefore PracticeView -> PracticeViewModel would get resolved....
SelectedAssembly is used in the case of separate views/viewmodels in different DLLs
Unless you aren't including anything we might need to know...
Upvotes: 3