WPF Prism region behavior and control specific events

Topics: Prism v4 - WPF 4
Oct 26, 2013 at 4:01 PM

When we use Prism regions,the module/ViewModels do not know about the underling control.All the handling is done in Region adapter and Region behavior.How can we handle control specific events and inform the ViewModels.

I was wondering to handle control specific events in Region behavior and publish them using EventAggregator.Is this the right approach for handling region control specific events?

Oct 27, 2013 at 9:01 AM

I think you can still avoid event aggregators here. Reason being in the adapter/behavior you will have access to the view and consequently you can access the view model (datacontext). May be you can put your function to be invoked in a viewmodelbase class, which you can invoke here.

Hope this helps. May be if you provide a more elaborate explanation of what you are trying to do, like what is your host control etc, then I could help you further.

Oct 28, 2013 at 5:25 PM
For example,you have navigation bar.You want to handle navigation bar sepcific events and then update the GUI.
Nov 1, 2013 at 3:15 PM
Hi tahirali_csc1,

Based on my understanding you would want to navigate through Views on a different Region which would be triggered from the Navigation bar's region Behavior.

Therefore, you could get the RegionManager inside NavigationBar Region Behavior, and then call RequestNavigate() on the specific region. This way you would achieve navigation on a different region without trouble.

If you then may need to configure or receive any parameters on each ViewModel when they get activated, you could make the ViewModels implement INavigationAware, and then set on the OnNavigatedTo() method the proper configuration needed.

You may find more information about Navigation on the following Prism Guide chapter:

I hope this helps,

Gabriel Ostrowsky