c# - Caliburn.Micro 在 App.xaml 的命名空间中没有 "Bootstrapper"

标签 c# windows-phone-7 windows-phone-8 windows-phone caliburn.micro

编辑:看来我终于成功了。我问过我之前提到的那个帖子的作者,他说这是一个已知问题。他还给了我一个解决方法(在帖子下方的评论中),所以我认为这个问题已经结束。但感谢大家花时间解决我的问题:)


我正在尝试使用 Caliburn Micro 框架学习 MVVM,但我从一开始就遇到了问题。我正在关注 this教程,我在 App.xaml 中得到了这样的代码:

<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>
        <caliburnMicro:Bootstrapper x:Key="bootstrapper" />
    </Application.Resources>
</Application>

但是我得到一个错误:

The name "Bootstrapper" does not exist in the namespace "clr-namespace:Caliburn".

我从 NuGet 存储库中获得了 Caliburn Micro 1.5.2。任何想法表示赞赏...

我的 Bootstrap :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caliburn.Micro;

namespace Caliburn
{
public class Bootstrapper : PhoneBootstrapper
{
    PhoneContainer container;

    protected override void Configure()
    {
        container = new PhoneContainer();

        container.RegisterPhoneServices(RootFrame);
        //container.PerRequest<MainPageViewModel>();

        AddCustomConventions();
    }

    static void AddCustomConventions()
    {
        //ellided  
    }

    protected override object GetInstance(Type service, string key)
    {
        return container.GetInstance(service, key);
    }

    protected override IEnumerable<object> GetAllInstances(Type service)
    {
        return container.GetAllInstances(service);
    }

    protected override void BuildUp(object instance)
    {
        container.BuildUp(instance);
    }
}
}

最佳答案

您应该定义自己的 Bootstrapper 类型,该类型派生自 Caliburn.Micro bootstrapper 类型之一。你的应用程序资源中的资源应该是这个 Bootstrap 的一个实例。

学习时最简单的选择是使用 Caliburn.Micro.Start NuGet package ,并查看其 Bootstrap 实现。 documentation还描述了您应该在 App.xaml 文件中使用的标记。

关于c# - Caliburn.Micro 在 App.xaml 的命名空间中没有 "Bootstrapper",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17548729/

相关文章:

c# - MVC - 保留模型结果以用于 ajax 方法而不通过 JSON 传入?

c# - Windows Phone 上的必应 map - 为图钉添加点击事件;显示更多细节

c# - 测量 UWP 应用程序的代码覆盖率

c# - 无需 wddm 1.1 即可运行 Windows 7 模拟器

xaml - 如何设置 HubSection 标题样式

unit-testing - Window Phone App 的单元测试

windows-phone-8 - 如何在 Windows Phone 8 中获取 IMSI 和 IMEI?

audio - 在WP8中同时播放多个音频文件

c# 在启动时锁定 Windows 计算机

c# - 从 If 语句内部调用组件