Silverlight, MVVM & Prism

Topics: Prism v2 - Silverlight 2
Apr 29, 2009 at 12:15 AM


I have a bit of an architecture conundrum. I’ve written a fairly large duplex client/server application using SL2 without using Prism. The server side is pretty well along. Where I am stuck is on the client. I am trying to implement an MVVM client architecture that gets its data from a duplex push instead of from a web service.

All examples that I can find show an MVVM model that has direct access to a web service or a database and can simply use linq to fulfill requests from the UI as the user clicks on various widgets.

In my case, the client is going to be constantly receiving updates. These updates need to make their way to the model and then have the UI update accordingly.

Does Prism support this model? Are there any examples?



Apr 29, 2009 at 8:35 PM

Hi Rick,


Prism programming model does support MVVM and you will find this pattern used in most Quickstart solutions. Although the CAL (Prism library) does not provide any special feature to facilitate your scenario, it will support it. This is because Prism was not specifically built to address web services or inter-application communication, so the Prism-v2 Quickstarts show a simplified access to the data to demonstrate the composability features.


You might find on the web or the silverlight forums several sample applications that demonstrate using duplex services in silverlight. Moreover Silverlight 3 simplifies duplex object model. You can read more on What's new with web services in Silverlight 3 Beta.


Hope it helps!


Matias Bonaventura

Apr 29, 2009 at 9:14 PM
Thank you for your answer. The question is not so much how Prism works with MVVM as it is how does Prism work with a model underneath MVVM that is receiving data from a duplex channel as opposed to fetching it from a webservice.

In one case, the user clicks on a widget which causes some data to be fetched from a server. In the other case, the model is being fed data on a background thread from which it must force a UI update.


Apr 30, 2009 at 12:11 AM
I have been working with the duplex services for a while now.  I use the EventAggregator to publish the appropriate message when recieved (pushed) from the server.  I have been following the recommendation to use an Infrastructure project and this is where the client side of the duplex is implemented.  The ViewModels subscribe for the events they are interested in.  This really seperates the concerns with the  ViewModels having no dependancy on the duplex service.  Works great.