I'm trying to create a strategy for handling popup forms for use throughout any part of my application. My understanding so far is that I will need a single UserControl
in the root of my MainWindow. This will be bound to its own ViewModel which will handle the messages that are sent within the app.
I'm using MVVM Light, and I'm fairly new to the Messenger
class.
Imagine a Master/Details scenario, where a list a objects are contained within a ListBox
. Selecting one of these items and clicking an Edit button would display a UserControl
which covers the whole screen. The user can then edit the selected item, and click OK to commit the change.
I want the UserControl
that is opened to be "generic" in a way that I can throw any (probably a ViewModel) at it... for it to render the ViewModel via a DataTemplate
and handle all the object changes. Clicking OK will callback to the sending class and persist the change as before.
Some situations where this would be useful are...
- Display error messages with no required user input (other than OK to close it)
- Display an edit form for a data item
- Confirmation dialogs (much like a standard MessageBox)
Can anyone provide any code samples of how I might acheive this?