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?
问题:
回答1:
.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:
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.
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.
回答2:
BTW - Shawn Wildermuth has a nice succinct Silverlight MVVM article in the March 2009 issue of MSDN Magazine
回答3:
See http://msmvps.com/blogs/theproblemsolver/archive/2009/04/07/using-model-view-viewmodel-with-silverlight.aspx for an example.
回答4:
Shawn Wildermuth's example combining RIA Services and MVVM:
http://wildermuth.com/2010/04/16/Updated_RIA_Services_MVVM_Example
Also, the PRISM download on codeplex has docs on this, and includes quickstarts and reference implementations for MVVM and RIA Services.
回答5:
I would ask Jonas Follesoe. He seems to be interested in MVVM in SL.
http://jonas.follesoe.no/