需要帮助在WPF表单之间传递数据并连续更新子表单 [英] Need help to pass data between WPF forms and update the child form contonously

查看:99
本文介绍了需要帮助在WPF表单之间传递数据并连续更新子表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我将使用线程监视来自硬件的数据.
但是当用户单击以加载表单时,我需要将数据传递给子表单.加载子表单后,它应该更新更改(数据)而不刷新.
在这种情况下最好的方法是什么.
请帮忙.
我正在使用WPF表单.

I have a requirement where in i will be monitoring data from hardware using thread .
But i need pass the data to a child form when user clicks to load the form.After the child form is loaded it should update the changes(data) without refreshing.
What is the best approach in such scenarios.
Please help.
I''m using WPF forms .

推荐答案

最简单的方法是使用在父表单和子表单之间共享的单个ViewModel.只要您以两种形式绑定到相同的ObservableCollection,就会看到相同的数据.
The easiest way to accomplish this is to use a single ViewModel that is shared between both the parent and the child form. As long as you bind to the same ObservableCollection in both forms, you will see the same data.


这篇关于需要帮助在WPF表单之间传递数据并连续更新子表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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