views:

162

answers:

1

When using Prism for composition in Silverlight how do I attach actions between modules?

Am I forced to use the event system or is there a way to set the TargetName for my Actions to the name of a UserControl in a different module?

For Example:

<Image Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="40" Source="/SilverlightDemo.MainToolbar;Component/Images/i_chart.png" Stretch="Fill" Canvas.Left="222" Canvas.Top="55">
                <i:Interaction.Triggers>
                 <i:EventTrigger EventName="MouseLeftButtonDown">
                  <Actions:ToggleCollapseAction

                            TargetName="HERE:/SilverlightDemo.Modules.TargetModule;Views/TargetModuleView" 
                            CollapseHorizontal="False" 
                            CollapseVertical="False"/>
                 </i:EventTrigger>
                </i:Interaction.Triggers>
            </Image>
+2  A: 

Hi,

As one of the benefits of using Prism is having decoupled applications, module are not aware of other modules (so, there is no knowledge about other module's user controls). Therefore, some kind of mechanism between them must establish communication between modules.

The most common way of doing this is using the Event Aggregator. If you want to reduce the code behind of your views, simply use a command in XAML and fire events in the ViewModel.

The following threads deal with similar questions:

Please let me know if this helps.

Damian Schenkelman

http://blogs.southworks.net/dschenkelman

dschenkelman