MVVM两个视图/视图模型之间传递数据 [英] MVVM Passing data between two views / view models

查看:163
本文介绍了MVVM两个视图/视图模型之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个页面:


  1. 1

  2. 第2页

和两个的ViewModels具有相同属性

and two ViewModels with the same properties:


  1. ViewModel1 结果
    属性:

    • FIRSTNAME1

    • LastName1


  • FIRSTNAME2

  • LastName2

现在我想ViewModel1之间传递数据(属性),以ViewModel2,并retrive在第2页上的这些数据。
我该如何实现这一目标?

Now I want to pass data(properties) between ViewModel1 to ViewModel2, and retrive this data on the Page 2. How do I achieve this?

推荐答案

您可以看看 MVVMLight 的使者。 <一href=\"http://jesseliberty.com/2011/01/06/windows-phone-from-scratch%E2%80%93mvvm-light-toolkit-soup-to-nuts-3/\"相对=nofollow>在这里的是,可以指导你的归途的教程。基本上,这个想法是使用信使这是独立于您查看/的ViewModels从/给他们发送消息。您的浏览/登记的ViewModels和发送包含属性的值要传递沿着特定的消息。

You could take a look at MVVMLight's Messenger. Here's is a tutorial that could guide you on your way. Basically, the idea is to use a messenger that's independent from your Views/ViewModels to send messages from/to them. Your Views/ViewModels register and send specific messages that contain properties values you want to pass along.

这篇关于MVVM两个视图/视图模型之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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