Communication between Two Modules without using EventAggregator

Topics: Prism v4 - WPF 4
Jun 8, 2010 at 2:09 PM

Hello,

I want to communicate between two modules without using EventAggregator, as well as without giving reference of module.

Is there any way to do this kind of Stuff ?

Thanks,

Rajnikant Rajwadi

Developer
Jun 8, 2010 at 7:52 PM

Hi Rajnikant,

The EventAggregator is not the only way you can use to communicate between two modules without directly referencing them. Depending on your requirements, you could use the different approaches stated on this article of the prism documentation.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Jun 9, 2010 at 10:31 AM

Hi guidomaliandi,

I see this article, but i can not find solution over there.

See my problem is

I have one module, that module have a view that hold a popup control. inside this popup control I have a region that load another view from different module.

I can do this. But problem is that I have to pass one value.

I dont want to do this thru event aggregator.

can u help me for this ?

Thanks,

Rajnikant Rajwadi

 

Jul 23, 2010 at 1:37 PM
Hi Rajnikant, Did you any solution for your problem? I am also having the same problem. If you get any solution or workaround please share that. Regards, Harish
Jul 23, 2010 at 2:52 PM
Edited Jul 23, 2010 at 3:43 PM

Hi guys,

Based on our understanding you need to communicate two modules without using event aggregator. There are 4 different ways for communication supported by Prism out-of-the-box.

However, based on your specs you could use Shared Services (see the Shared Service section), which is also cross-module like Event Aggregator. From the documentation at MSDN: Service instances are shared across modules, so you can share data and pass messages between modules.

Therefore, it seems to be the right solution for you, and it is simple to use by registering your service, as shown in the following code:

protected void RegisterViewsAndServices()
{
    _container.RegisterType<IMarketFeedService, MarketFeedService>(new ContainerControlledLifetimeManager());
    //...
}

For more information about this, you could take a look at the following documentation section:

Additionally, in the Stock Trader RI, you'll find an example (see the RegisterViewsAndServices method in MarketModule.cs).

Please let me know if this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero

Aug 22, 2011 at 3:17 PM
fantivero wrote:

protected void RegisterViewsAndServices()
{
    _container.RegisterType<IMarketFeedService, MarketFeedService>(new ContainerControlledLifetimeManager());
    //...
}

For more information about this, you could take a look at the following documentation section:

 

fantivero--

The code you cite above is out of date. It no longer appears in the Stock Trader RI example. The comments in "MarketModule.cs" say this: "This module is intentionally left empty because views, services, and other types are discovered through declarative attributes. View registration for this module is done through the ViewExportAttribute."

So basically, the MSDN documentation is no longer useful. I am unable to find examples of the "new" way of the ViewExportAttribute approach.

Thanks, though, for the "How to" link. I hand never found that page. It's probably written for VS2008, but at least it's something that appears to be useful.

Developer
Aug 23, 2011 at 2:04 PM
Edited Aug 23, 2011 at 3:01 PM

Hi,
You could try downloading the Prism Training Kit, where you might find some useful examples, like the one in the MEF Lab, exercise 2 which implements ViewExport Attribute.

I hope you find this information handy.

Agustin Adami
http://blogs.southworks.net/aadami