Caliburn.Micro does not have “Bootstrapper” in a namespace in App.xaml

有些话、适合烂在心里 提交于 2019-12-06 17:03:28

You should define your own Bootstrapper type which derives from one of the Caliburn.Micro bootstrapper types. The resource in your application resources should then be an instance of this bootstrapper.

The easiest option whilst learning is to use the Caliburn.Micro.Start NuGet package, and have a look at its bootstrapper implementation. The documentation also describes the markup you should use in your App.xaml file.

I think everyone got confused because you named your own namespace caliburn so they so thought you are trying to create an instance of the framework's bootstrapper so i suggest to alter your naming conventions. With that out of our way, instead of the bootstrapper directly into the application resources, try putting it in a resource dictionary like this this:

<Application
x:Class="Caliburn.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:caliburnMicro="clr-namespace:Caliburn">
<!--Application Resources-->
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <local:Bootstrapper x:Key="bootstrapper" />
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

I had the same problem and it´s easy to solve. You need to override the method OnStart in your Bootstrapper class and in this method set which is your root view.

protected override void OnStartup(object sender, StartupEventArgs e)
{
    DisplayRootViewFor<ViewModels.ShellVM>();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!