I got my Prism 4 + Ria Services Silverlight 4 App

Topics: Prism v4 - Silverlight 4
Sep 5, 2011 at 8:13 PM
Edited Oct 20, 2011 at 9:16 PM


I am working to develop a "real life" , teachable, and very simple Prism + "Ria Services" Application, to share with the community
(is a work in progress)

When done I plan to release it in the same way I have done here


Sep 6, 2011 at 5:16 PM


Thank you for sharing your experience on the subject. In case you find a specific issue regarding Prism, please create a new thread in the discussions so that we analyze your problem.

As for the samples about Prism, you might find the Prism Training Kit useful, where there are hands on labs with step-by-step guidance to fulfill certain scenarios in Prism.

Additionally, you might find the QuickStarts and Reference implementations in Prism useful. Finally, you can check some of these blogs, where you might find guidance and How-Tos for specific Prism scenarios:


Guido Leandro Maliandi

Sep 17, 2011 at 4:29 PM
Edited Oct 20, 2011 at 9:13 PM

Thank you Guido, Great documentation

In Module5 / ViewModels / MasterViewModel / line 54

I try to use that event so when a customer is selected, his/her orders will display in the Grid to the right

DataItemsCv.CurrentChanged += new EventHandler(SelectedItemChanged);

My main goal is not going to Complex and keeping the application very simple and teachable

Main Page


Sep 19, 2011 at 10:38 PM

Hi Oscar,

I downloaded your sample, so far I couldn't find an error in your Event Aggregator implementation. On the other hand when I uncomment the aforementioned line of code, I get a NullReferenceException when trying to subscribe to that event. Is this the error you are mentioning?

Waiting for your answer.


Agustin Adami

Sep 19, 2011 at 11:25 PM
Edited Oct 20, 2011 at 8:57 PM


Master /Child. 

Customer/ Orders

but very simple, and with the minimum amount of code possible.. with the great "Code Practices" prism teaches

Sep 20, 2011 at 2:26 PM

Hi Oscar,

We examined your sample again and found a possible way you could achieve the scenario you've mentioned. As you're probably aware of, you could use the Event Aggregator to achieve communication between loosely coupled components; and in this case, it seems to suit your requirements well.

So, in order to be able to use the Event Aggregator to notify your Orders View Model that the customer in the Customers View has changed, you need to have a notion of which is the selected customer. We thought that you could make use of the delegate command you have defined in your Customers View Model to pass that information to the View Model, so that you can call an event with such information from there.

We modified the Command1 command to be of type DelegateCommand<Customer>, and added a CommandParameter in the button in the view (as shown in the code snippet below):

<Button Grid.Row="0" Grid.Column="1" Content="Cmd" Width="35" Margin="4" HorizontalAlignment="Right"
                prism:Click.Command="{Binding Command1}" prism:Click.CommandParameter="{Binding ElementName=CustomersDataGrid, Path=SelectedItem}" />

This way, when clicking that button, the execute method of the command will receive the selected customer as a parameter, which you can thus use to obtain the necessary information to publish your event through the Event Aggregator (for example, the ID of your customer). The following code snippet illustrates the aforementioned:

private void ExecuteCommand1(Customer commandParameter)

Since you should have previously subscribed to that event in your Orders View Model (as in the following snippet), you can add the corresponding logic in the orders view to react to that event accordingly (retrieving the appropriate data and updating the orders displayed):

        public OrderViewModel( IEventAggregator eventAggregator, IOrderServiceAgent serviceAgent)

I hope you find this helpful.

Guido Leandro Maliandi

Sep 22, 2011 at 6:22 PM
Edited Sep 22, 2011 at 6:26 PM


Based on my understanding of your scenario, after watching your video, I realize that a better approach to fulfill it, could be to define a Custom Behavior in a common project, which will contain the logic for an attached behavior that should bind the DataGrid event in your CustomersView with the Command in the ViewModel. You will find samples of this in the End solution of the Communication exercises of the Prism Training Kit v4.0.

Particularly you might take a look at the following code files of Exercise 2:

  •      Prism.Workshop\Workshop.Infrastructure\Behaviors\DataGridSelectedItemCommandBehavior.cs
  •      Prism.Workshop\Workshop.Infrastructure\Behaviors\ProductsListView.xaml

I hope you find this useful.

Agustin Adami