tags:

views:

55

answers:

3

Hello

I am using Prism in an application and I need a way to run call a function every time a module is requested. The thing is that this function will query the database for some items, and I need to do this every time the module is requested by pressing the module item buttom from a menu. I tried adding this to the constructor, but the problem is that the constructor is called during the initialization of the application from the bootstrap!

Is there a simple way to do this?

+2  A: 

How are you requesting your module? One way to do this is to use EventAggregation, and have the modules listen for specific events which will tell them they are requested. If you use EventAggregation to request you modules you will have an event handler that handles the request event. Hopefully you should be able to use your event handler to call your function too.

stiank81
A: 

I'm pretty sure that the Initialize function is called each time the module is loaded. You can just put code in there.

thepaulpage
A: 

when using unity as IoC container, and you request the module using unity, maybe this could work by creating your own unity interceptor (Microsoft.Practices.Unity.Interception namespace)

Joachim Kerschbaumer