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

落爺英雄遲暮 提交于 2020-01-01 18:09:11

问题


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:

  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.




回答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/



来源:https://stackoverflow.com/questions/665204/how-to-combine-net-ria-services-with-mvvm-in-silverlight-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!