The scenario:
- Parent Window loads, fills data (grid, labels, etc.)
- User clicks a button, firing a bound command in the Parent Window's ViewModel, launching an Edit Dialog
- User makes changes in the Edit Dialog and clicks "Accept", saving some information to a database
- Parent Window's ViewModel recognizes that something happened (noticing that
dialog.DialogResult == true
), and that it should refresh it's data and any relevant bindings
Also consider that step 3 could fail for some reason (a complex business logic rule could fail and the user needs to tweak something, the database update could throw an exception, zombie invasion, etc.), so the Edit Dialog might have to stay open.
ViewModels shouldn't (to my understanding) know much/anything about its associated View, and therefore, it would be difficult for the ViewModel to communicate to the View:
"Hey, the Save operation completed successfully! Go ahead and close now!"
Or:
"Whoa! There was a problem that needs to be taken care of before you can close... wait a tick."
The Question:
How is something like this elegantly accomplished, with as little xaml.cs
code as possible (preferably none)?