2014-04-07 109 views
1

我無法找到任何意見Caliburn.Micro。引導程序啓動,但是然後出現一個通用窗口,即使存在ShellView.xaml,也不存在任何視圖ShellViewModel。做什麼?找不到視圖模型

引導程序

public sealed class AppBootstrapper : BootstrapperBase 
{ 


    private IKernel _kernel; 

    #region Bootstrapper 

    public AppBootstrapper() 
    { 
     Start(); 
    } 

    protected override void Configure() 
    { 
     _kernel = new StandardKernel(); 
     _kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope(); 
     _kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope(); 
     _kernel.Bind<IShell>().To<ShellViewModel>(); 
    } 

    protected override void OnStartup(object sender, System.Windows.StartupEventArgs e) 
    { 
     DisplayRootViewFor(typeof (IShell)); 
    } 

    protected override void OnExit(object sender, EventArgs e) 
    { 
     _kernel.Dispose(); 
     base.OnExit(sender, e); 
    } 

    protected override object GetInstance(Type serviceType, string key) 
    { 
     if (serviceType != null) { 
      return _kernel.Get(serviceType); 
     } 

     throw new ArgumentNullException("serviceType"); 
    } 

    protected override IEnumerable<object> GetAllInstances(Type serviceType) 
    { 
     return _kernel.GetAll(serviceType); 
    } 

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

    #endregion 

    } 
} 

ShellViewModel

public sealed class ShellViewModel : Screen, IShell 
{ 

    public ShellViewModel() 
    { 
     DisplayName = "Hello"; 
    } 

} 
+0

日誌打開了嗎? –

+0

@DerekBeattie在Caliburn?我如何實現這一目標? – Acrotygma

+0

你有沒有StartupUri意外設置在App.xaml的應用程序元素中? – devdigital

回答

2

您可能需要使用SelectAssemblies的覆蓋告訴CM裏的 「爲.dll」 S是意見和的ViewModels。否則它將永遠找不到它們。我通常也將這個用於我的項目,它應該可以解決您的問題。