How to combine .NET RIA Services with MVVM in Silverlight 3

mvvmsilverlightsilverlight-3.0wcf-ria-services

The .NET RIA Services are described as an n-tier framework for Silverlight. I have been wondering what the relation is between this framework and the Model-View-ViewModel pattern. Are they in conflict or can you see the potential for synergic combination?

Best Answer

.NET RIA Services and MVVM are synergistic, and aren't in conflict.

For example, if I write a Catalog domain service that exposes Products and Categories on the server, and correspondingly have a Catalog domain context on the client... then the following are options to use depending on the scenario:

  1. Write a view model that wraps the Catalog domain context and exposes properties that hand out subsets of data that has been loaded into the Products and Categories lists. And expose operations that turn around and invoke methods on Catalog.

  2. Expose a Catalog out of the view model. Often this is perfect for read-only scenarios.

In either case your view model can take care of initializing the Catalog and customizing its creation, setup etc.

Hope that helps get you started in thinking how these might be effectively combined.

We'll definitely be showing some of this working in future samples we put out.