WPF中的不同窗口之间的数据共享 [英] Data sharing between different windows in WPF

查看:1385
本文介绍了WPF中的不同窗口之间的数据共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个WPF应用程序配置不同类型的使用数据采集卡的传感器的数据采集。我的第一个窗口,需要从用户对不同的参数输入,我想在我所有的窗户进一步使用这些。什么是存储所有这些的最佳方式。




  1. 请一个单独的类,并将其储存在类的所有静态字段。

  2. 存储它们在我的主窗口类的字符串数组。


解决方案

如果你想要做的正确方法;看看MVVM模式:





谷歌MVVM的详细信息;)


I'm making a WPF application to configure data acquisition from different types of sensors using DAQ cards. My first window takes input from user regarding different parameters and I would like to use these in all my further windows. What is the best way to store all these.

  1. make a separate class and store them all as static fields in the class.
  2. store them in a string array in my mainwindow class.

解决方案

If you want to do it the right way; take a look at the MvvM pattern:

Google "mvvm" for more info ;)

这篇关于WPF中的不同窗口之间的数据共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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