如何从不同的ViewModels修改数据网格 [英] How do I modify a datagrid from diffrent ViewModels

查看:68
本文介绍了如何从不同的ViewModels修改数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个UserControl的视图。每个UserControl都有一个ViewModel。 ViewModel继承自baseViewModel,它实现了INotifyPropertyChanged的东西。

其中一个viewmodel包含一个datagrid,另一个包含一个textbox和一个apply按钮。独立一切都很好。但我想从其他ViewModel的列表中的文本框中应用输入的数字。



有没有人有一个虚拟的友好解释来实现这个目标?



edit /



< img src =http://image-upload.de/thumb/ZAscqq/5285303a83.jpgalt =image-upload.deborder =0> < br $> b $ b

我应该使用哪种方式? No1直接通信ViewModel1< - > ViewMode2或No2 ViewModel1< - > Model< - > ViewModel2

I have a View with multiple UserControls. Each UserControl has its one ViewModel. The ViewModels inheritances from a baseViewModel, which implements the INotifyPropertyChanged stuff.
One of the viewmodel contains a datagrid and another has a textbox and an apply button. Independently everything is working fine. But I would like to apply the entered number from the textbox in the list from the other ViewModel.

Does anyone have a dummy friendly explanation to achieve this?

edit/

<img src="http://image-upload.de/thumb/ZAscqq/5285303a83.jpg" alt="image-upload.de" border="0">

Which way should I use? No1 Direct comunication ViewModel1 <-> ViewMode2 or No2 ViewModel1<->Model<->ViewModel2

推荐答案

请检查以下代码是否适用于您



http://code.msdn.microsoft.com/Basic-WPF- Code-4aab4e1a [ ^ ]



Artha
Please check, whether the below code will use for you

http://code.msdn.microsoft.com/Basic-WPF-Code-4aab4e1a[^]

Artha


这篇关于如何从不同的ViewModels修改数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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