0

When using code behind, the code looks like this:

AnotherWindow x = new AnotherWindow();
x.Show() ;
// or x.ShowDialog()

But how can I achieve this using MVVM? Specifically Prism?

2 Answers2

0

In case you need to build a dialog for asking user login input or progressing dialog, MahApps.Metro can be a useful toolkit as it provides you with some built-in dialog UI/functionalities with MVVM pattern. For more information, check some examples here: https://mahapps.com/controls/dialogs.html

popsiporkkanaa
  • 678
  • 1
  • 9
  • 17
0

In Prism, there's the InteractionRequest for short-lived dialogs. If you're looking for a long living dialog, like a second application window or shell, you're stuck with new Window ... Show.

To make your dialog service mvvm-friendly, you should hide it behind an interface and make it as generic as possible. Using view model first here eliminates the need to specify a window type, because you can provide a default window that just contains one large ContentControl, and the view can be mapped as DataTemplate.

Haukinger
  • 10,420
  • 2
  • 15
  • 28