WPF中的不同窗口之间的数据共享 [英] Data sharing between different windows in WPF
本文介绍了WPF中的不同窗口之间的数据共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做一个WPF应用程序配置不同类型的使用数据采集卡的传感器的数据采集。我的第一个窗口,需要从用户对不同的参数输入,我想在我所有的窗户进一步使用这些。什么是存储所有这些的最佳方式。
- 请一个单独的类,并将其储存在类的所有静态字段。
- 存储它们在我的
主窗口
类的字符串数组。
解决方案
如果你想要做的正确方法;看看MVVM模式:
- http://en.wikipedia.org/wiki/Model_View_ViewModel
- 简介:的 http://www.codeproject.com/Articles/278901/MVVM-Pattern-Made-Simple
- 一个很好的工具,因为这是Mvvmlight( http://mvvmlight.codeplex.com )
谷歌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.
- make a separate class and store them all as static fields in the class.
- 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:
- http://en.wikipedia.org/wiki/Model_View_ViewModel
- Introduction: http://www.codeproject.com/Articles/278901/MVVM-Pattern-Made-Simple
- A nice toolkit for it is Mvvmlight ( http://mvvmlight.codeplex.com )
Google "mvvm" for more info ;)
这篇关于WPF中的不同窗口之间的数据共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文