如何在 Silverlight 3 中将 .NET RIA 服务与 MVVM 结合起来? [英] How to combine .NET RIA Services with MVVM in Silverlight 3?

查看:39
本文介绍了如何在 Silverlight 3 中将 .NET RIA 服务与 MVVM 结合起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET RIA 服务被描述为 Silverlight 的 n 层框架.我一直想知道这个框架和 Model-View-ViewModel 模式之间的关系是什么.它们是否存在冲突,或者您能看到协同组合的潜力吗?

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?

推荐答案

.NET RIA Services 和 MVVM 是协同的,并不冲突.

.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. 编写一个视图模型,该模型包装 Catalog 域上下文并公开分发已加载到 Products 和 Categories 列表中的数据子集的属性.并公开在 Catalog 上反转和调用方法的操作.

  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.

从视图模型中公开目录.这通常非常适合只读场景.

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.

这篇关于如何在 Silverlight 3 中将 .NET RIA 服务与 MVVM 结合起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆