I'm in the pre-design stages of a small application that I'd like to write using Caliburn.Micro and C# / WPF. I'm still learning the framework, but I like what I see so far.
The application I intend to build is a process memory search/scan utility, with ASM disassembly and memory browsing capability. These three concerns - search/scan, ASM disassembly, and memory browsing - I'd like to be handled by three or more separate windows. The search/scan portion will comprise the main application shell, while the other two functions (which can be invoked multiple times simultaneously) will use separate windows invoked from actions on the shell.
My question is this: how do I launch new windows from within the shell (or some other) view model? I know I have to pass in another sort of view model for rendering in a new window - but it's that new window busine开发者_如何学运维ss that's confusing me.
Caliburn.Micro provides a WindowManager
type with a Show
method which can display a view model in a new window, and if that view model implements the appropriate Caliburn.Micro interfaces, the WindowManager
will ensure the view model goes through the usual life cycle (i.e. it calls OnActivate
, OnDeactivate
etc). If your view models derive from the Screen
type, then this will be the case.
WindowManager
implements the IWindowManager
interface, so you can inject this abstraction as a dependency into your ShellViewModel.
If the associated view is not a Window
, but a UserControl
, then the WindowManager
will also wrap the UserControl
in a Window
so that it can be displayed.
精彩评论