Is there any consensus regarding best practices for dialog boxes in MVVM (for WPF)? I saw him approaching in two ways:
An intermediary (EventAggregator, EventBus, or whatever you like to call) that sends a "RequestsDialog" message and waits for a "DialogProcessed" message.
A dialog declared in the xaml view itself, which is tied to the caller's view model and displayed via Command or EventTrigger or something like that.
I am trying to figure out which way is better and I need help.
My problem is C # 1 (and always has been), what's the best way to control the amount of request and response messages? I mean, say, I have both βlocalβ messages and βglobalβ application messages processed by my intermediary .... how can I make sure that my ViewModel can still receive global messages ... but in the same time that another ViewModel in the current window does not accidentally receive a DialogProcessed message intended for the active ViewModel.
Run the following script:
- 1 Window
- 2 UserControls, each of which is tied to independent ViewModels
- ViewModel1 sends a RequestConfirmation message and waits for a ConfirmationResponse message
- I also have global messages to receive in ViewModel1 (e.g. RequestCloseWindow message).
How to prevent ViewModel2 from receiving a ConfirmationResponse message for a RequestConfirmation message initiated by ViewModel1?
source share