Question

I'm relatively new to MVVM concepts and Caliburn and I'm blocked with an issue. The application I'm working on uses Mahapps.Metro for "metro-like" design on WPF and I'm using Caliburn Micro for MVVM goodness.

I have created my application in the following way:

  • ShellView that is mahapps metro's MetroWindow, it contains some design stuff that I will want on all views (a logo mainly) and a ContentControl bound to the ActiveItem
  • The ShellViewModel derives from Conductor<Screen> and implements IShell
  • I have a ContentView that is a standard UserControl with his ContentViewModel inheriting from Screen

Now, in the ContentView, I need to display a Flyout on a user click. Flyout are set on MetroWindow's Flyouts property. So I'm a bit lost on how from my ContentViewModel I should display this flyout on the ShellView.

Should I use the event aggregator and send an event? Should I have the flyout defined as a ContentControl on the ShellView and change it depending on what type of flyout I should display?

Also I would like that the flyout is display a bit like a ShowDialog. The flyout is to display a relatively complex "load file" screen. So my code that asks to display it should know when the user has validated or canceled the screen and process the result of the loaded files.

I will have other "content" views that will also display their own flyouts.

Thanks for your help.

Was it helpful?

Solution

MVVM encourages separation of the logic from presentation so I would recommend using an Event Aggregation system similar to the Messenger subsystem in MVVMLight. You will be building a system that can be reused across your application and not tying on modal dialog to a specific source.

Your View binds to a ViewModel Command, fire an event, a subscriber ViewModel listens and catches, displays Flyout as a View.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top