What would be a good way to return a result from a non-modal notification?
I am working on adding a non-modal notification system to my application. The notifications will be unobtrusive pop-ups that appear in the corner of the a开发者_JAVA技巧pp. There can be more than one notification at a time.
Most of the time these notifications will not require user input, but sometimes they will be used to get user input for things that do not require an immediate response.
Any suggestions?
The easiest way to get result from an asynchronous behavior is using event system. You notification seems have an asynchronous behavior, Using routed event is good where you can bubble your event from your notification and catch it on the parent window.
but if you having trouble to use routed event then you can try event aggregator pattern. Brent Edwards has nice blog post about that.
good luck
Typically I use a PRISM's EventAggregator to register to be notified in these cases. Also MVVMLight has a nice messenger that allows different ViewModels to talk to one another in a decoupled way.
精彩评论