Note that there are some explanatory texts on larger screens.

plurals
  1. POCaliburn Micro WPF Window Management
    text
    copied!<p>I'm wanting to start a WPF application using caliburn.micro so I can use TDD as much as possible, I've used caliburn.micro before with WP7 but WPF seems to be a different ship, and the documentation isn't as complete as that for WP7.</p> <p>I've set up the project with my Bootstrapper</p> <pre><code>public class ApplicationBootstrapper : Bootstrapper { private SimpleContainer _container; private WindowManager _windowManager; protected override void Configure() { _container = new SimpleContainer(); _windowManager = new WindowManager(); _container.RegisterSingleton(typeof(MainViewModel), "MainViewModel", typeof(MainViewModel)); _container.RegisterSingleton(typeof(DataViewModel), "DataViewModel", typeof(DataViewModel)); } protected override object GetInstance(Type service, string key) { return _container.GetInstance(service, key); } protected override IEnumerable&lt;object&gt; GetAllInstances(Type service) { return _container.GetAllInstances(service); } protected override void BuildUp(object instance) { _container.BuildUp(instance); } protected override void OnStartup(object sender, System.Windows.StartupEventArgs e) { _windowManager.ShowWindow(_container.GetInstance(typeof(MainViewModel), "MainViewModel")); } } </code></pre> <p>and this loads the MainView fine, which made me think I had won but I was then wanting to move on and have another view/viewmodel setup but for the life of me I cannot get the WindowManager to be passed through to my ViewModel in order to load more views (As I did with the NavigationService in WP7)</p> <p>Here is my MainViewModel code</p> <pre><code>public class MainViewModel : BaseViewModel { private readonly DataViewModel _dataViewModel; private readonly IWindowManager _windowManager; public MainViewModel(IWindowManager windowManager, DataViewModel dataViewModel) { _dataViewModel = dataViewModel; _windowManager = windowManager; } public string Title { get { return ApplicationTitle; } } public void BtnNew() { System.Diagnostics.Debug.WriteLine(_windowManager == null); } public void BtnLoad() { MessageBox.Show("Sorry, not yet implemented"); } } </code></pre> <p>But the Window Manger and the DataViewModel is always null, when I searched the internet for a solution I found that it was indeed the WindowManager that I wanted to utilize, and something about the MEFBootStrapper? but I would have thought that the framework conventions that I used on WP7 would have transferred a tonne better than it seems to be.</p> <p>The Simple Container is just the <a href="http://caliburnmicro.codeplex.com/wikipage?title=SimpleContainer&amp;referringTitle=Documentation" rel="nofollow">recipe</a> provided by caliburn.micro on their site, and the one I used in WP7 applications</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload