Global Variables in Prism

Topics: Prism v1
Aug 19, 2009 at 10:29 AM

Hi ,

Im new to Prism V1.  My Application consist of 3 regions,One region ->Menu ,Second Region ->TreeView,Third region -> Workspace.

When user selects an treeView Node ,I am raising a Event Aggregration event and loading corresponding module.

I need to store treenode in a global variable ,so tht entire application[All regions can access variable] can access tht global variable.

Currently im using following way

System.AppDomain.CurrentDomain.SetData("TreeNodeObject", treeNode);

is there any provision in WPF Prism ,where i store variable globally ,so tht All regions can access those global variables.

 

Please respond me ASAP

 

With Regards,

Mahender

Aug 19, 2009 at 5:40 PM

Hi Mahender,

To make a particular object available for the entire application you can register it in the container of your application and resolve it when you require (another option could be having a service expose different objects that represent the state of your app, more about that in this thread). You can check how this is done here (if you are using Unity).

Take into account that the objects registered in the container should not break the applications decoupling, so you should be careful with the items you register in it.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman