开发者

I need to run a function everytime a module is requested using Prism

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 butt开发者_如何学JAVAom 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?


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.


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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜