This project has moved. For the latest updates, please go here.

Sharing data between parts

Nov 26, 2010 at 2:10 PM

Hi all!

I´m new to MEF and got a problem.

In my Application I dynamically load xap-files. All works fine.

But now I want to make data from one xap available to the other xap´s , e.g. a user logs on and the other xap´s should get some information about it like the username. The user logs on, when all xap´s are loaded, so I cannot use an Export, at least it doesnt work.

Anyone got an idea?

Greetz, Tom

Nov 26, 2010 at 7:34 PM

To share data between the xaps, create a part which exports user profile data, for example a UserProfilePart. Make the part implement a contract like IUserProfilePart that is in a common contracts library which all the other xaps can reference. By default all parts in MEF are shared, thus whoever calls for that part willl get the same instance. Thus the main xap can access the part  and populate the user info, with secondary xaps then accessing it to read the info.

Jan 18, 2011 at 1:46 PM

Another way will be to use messenger system. For example you can use MVVM light library and send message from one part to another (assuming another part is registering messenger receiving callback)