I have a WPF application which uses Prism and MVVM architecture.
Is there any way to handle events in ViewModel? I guess there should be something for it in Prism but I can't find it.
I have a WPF application which uses Prism and MVVM architecture.
Is there any way to handle events in ViewModel? I guess there should be something for it in Prism but I can't find it.
For some context on the comment, above:
The Xaml page will expect your viewmodel to expose properties and Commands. Properties provide the data to the Xaml and the Commands provide the mechanism for the view to push user-driven events back to the viewmodel.
Prism has a series of Commands to help you do this:
DelegateCommand: Link to Delegate Command CompositeCommand Link to Prism documentation for Composite Commands
If you want your viewmodels to fire events to notify other services/viewmodels/stuff that something has happened then the best way to do this is to use the EventAggregator. The EventAggregator uses a publisher/subscriber model to allow object to subscribe or publish an event without having to worry if anyone is listening. Documentation for this can be found here: Event Aggregator documentation