编辑:看来我终于让它工作了。我问了我之前提到的那篇文章的作者,他说这是一个已知问题。他还给了 mi 一个解决方法(在帖子下方的评论中),所以我认为这个问题已经结束。但是感谢大家花时间解决我的问题:)
我正在尝试使用 Caliburn Micro 框架学习 MVVM,但我从一开始就遇到了问题。我正在关注本教程,并且在 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>
但我得到一个错误:
名称空间“clr-namespace:Caliburn”中不存在名称“Bootstrapper”。
我从 NuGet 存储库获得了 Caliburn Micro 1.5.2。任何想法表示赞赏...
我的引导程序:
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);
}
}
}