私はCaliburn.Microを使い始めました。Caliburn.Microは異なるアセンブリのViewとViewModelを一致させることはできません
ShellView(usercontrol)をTest.Appアセンブリに、ShellViewModelをTest.ViewModelアセンブリに配置して簡単なサンプルソリューションをブートストラップしようとしています。
「Caliburn.Test.ViewModel.ShellViewModelのビューが見つかりません」というテキストのウィンドウが表示されます。
しかし、ViewModelを.Appアセンブリに移動すると、完全に機能します。
namespace Caliburn.Micro.Test.ViewModel
{
public interface IShell
{
}
public class ShellViewModel : IShell
{
}
}
:これはCaliburn.Micro.Test.ViewModelアセンブリ内の私のViewModel(クラスライブラリ)である
namespace Caliburn.Micro.Test
{
public class AppBootstrapper : BootstrapperBase
{
SimpleContainer container;
public AppBootstrapper()
{
this.Start();
}
protected override void Configure()
{
container = new SimpleContainer();
this.container.Singleton<IWindowManager, WindowManager>();
this.container.Singleton<IEventAggregator, EventAggregator>();
this.container.PerRequest<IShell, ShellViewModel>();
}
protected override object GetInstance(Type service, string key)
{
var instance = this.container.GetInstance(service, key);
if (instance != null)
return instance;
throw new InvalidOperationException("Could not locate any instances.");
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return this.container.GetAllInstances(service);
}
protected override void BuildUp(object instance)
{
this.container.BuildUp(instance);
}
protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
{
this.DisplayRootViewFor<IShell>();
}
protected override IEnumerable<System.Reflection.Assembly> SelectAssemblies()
{
var assemblies = new List<Assembly>()
{
Assembly.GetExecutingAssembly(),
Assembly.Load("Caliburn.Micro.Test.ViewModel"),
};
return assemblies;
}
}
}
:これはCaliburn.Micro.Testアセンブリ内Bootstraper(実行可能)である
私の問題を解決するのに手伝ってもらえますか? ありがとうございました! :D
あなたは 'SelectAssemblies'をオーバーライドしましたか?ビューを含むすべてのアセンブリをCMに提供する必要があります – Charleh