在mvvm silverlight中的视图模型之间传递值 [英] pass values between viewmodels in mvvm silverlight

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

问题描述

我正在使用mvvm在Silverlight中设计Web应用程序.

我的情况:-
我有一个将数据绑定到其上的子窗口..如果我单击数据网格中的任何行并单击编辑按钮,则另一个子窗口应打开,并带有与数据网格所选项绑定的文本框...两个子窗口都有单独的视图模型和型号..

我的问题:-
在datagrid中选择一行后,我单击编辑"按钮,但是值未绑定到所选项目的文本框中...我的问题是当我将父项viewmodel(datagrid childwindow)中的selecteditem值传递给子viewmodel(edit childwindow)时所选项目为NULL ...

有人可以给我一个关于这个问题的建议吗?

i am designing a web application in silverlight using mvvm..

my scenario:-
i have a child window where the datas are binded to it..if i click any row in the data grid and click edit button another childwindow should open with textboxes binded from the selected item of data grid...both childwindows have separate viewmodels and models..

my problem:-
after selecting a row in datagrid i click the edit button,but the values are not binding in the textboxes of the selected item... my problem is when i pass selecteditem value from parent viewmodel(datagrid childwindow) to child viewmodel(edit childwindow) the selected items are NULL...

can anybody give me a suggestion for this problem???

推荐答案

您可以使用Action 委托在单击编辑"时返回到第一个视图.第二个视图.
You can use an Action delegate to go back to the first view when edit is clicked in the second view.


如果我理解正确,则不知道单击编辑按钮的位置.在这种情况下,您应该使用CommandParameter.
If I understand correctly you do not know in which row an edit button were clicked. In that case you should use the CommandParameter.
<button commandparameter="{Binding}" ...="" />


这篇关于在mvvm silverlight中的视图模型之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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