一个数据集2 wpf windows [英] One dataset 2 wpf windows

查看:77
本文介绍了一个数据集2 wpf windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我有一个简单的问题,想知道你们是否可以把我送到正确的方向。我有和2个wpf窗口的应用程序。一个MainWindow和一个窗口,我在其中从excel导入数据。导入的数据存储在数据集内的数据表中。

我的问题是,如何在窗口之间传递数据集,即如何在主窗口中访问数据表?

我试过找到一些但却无法理解它是如何工作的。有些人建议在主窗口中创建一个分部类。



类似



pulic partial class TransferData:Window





但是我没有丝毫的线索从那里开始以及如何使用这种方法传递完整的数据集。



很抱歉缺少代码,我真的不知道该怎么做。如果有人能指出我正确的方向或对这个问题有一些意见,我将非常感激。我确信这不是第一次有人问这样的事情(只是找不到任何具体的东西可以帮助我)。



谢谢

Hey guys,

I had a quick question and was wondering if you guys could send me in the right direction. I have and application with 2 wpf windows. One MainWindow and a Window in which I import data from excel. The data that is imported is stored within a datatable inside a dataset.
My question is, how do you pass the dataset between the windows i.e. how do I access the datatable in the main window?
I have tried finding something but can't really understand how it works. Some people suggest to create a partial class in the main window.

something like

pulic partial class TransferData : Window


but I have not the slightest clue where to go from there and how to pass a full dataset with this method.

Sorry for the lack of code, I really don't know how to do this. I'd be very grateful if someone can point me in the right direction or has some input on this problem. I am sure it wasn't the first time someone asked something like this (Just cant find anything specific that would help me).

Thanks

推荐答案

在这种情况下,您不应该将数据访问从一个窗口传递或委托给另一个窗口,这将违反应用程序体系结构的正确分层。您必须尽可能地分离数据模型或数据层,尤其是从UI。在最简单的情况下,您应该让数据层由单独的类表示(它也可以是不同的程序集,或者,如在一些更大的体系结构中,甚至是层之间具有适当通信的不同层),并且通过两个窗口引用此类。



此外,如果它只基于一个窗口,你可以有更好的UI(我不算一些少量的模态窗口)。在这种单窗口方法中,您可以使用不同的选项卡页面,一次显示一个不同的页面,某种类似手风琴的面板,或者像在Visual Studio中一样,一些可停靠的面板与选项卡结合使用。



-SA
In this case, you should not pass or delegate data access from one window to another, it would violate proper layering of the application architecture. You have to separate data model or a data layer as well as possible, especially from the UI. In the simplest case, you should have the data layer represented by a separate class (it could be also different assembly, or, as in some bigger architectures, even a different tier with proper communication between tiers), and reference this class by both windows.

Besides, you could have much better UI if it is based on only one window (I don't count some small number of modal windows). In this single-window approach, you can have different tab pages, different pages showing one at a time, some kind of accordion-like panels, or, like in Visual Studio, some dockable panels combined with tabs.

—SA


感谢您的回复,因此您建议我应该将数据集完全放在不同的类中然后能够从两个窗口访问该类?我不是单窗口方法的忠实粉丝,因为我希望能够使用多个监视器来处理数据并可以选择正确排列它们。

基本上这个程序将用于绘制数据并对其进行计算。因此我需要一个带数据的窗口,一个带图形的窗口等。

你认为一个好的解决方案是在程序后面有一个sql数据库吗?即导入数据将其保存到数据集内的数据表并将其推回到sql数据库然后用它来处理其他窗口中的数据?

你有什么想法我应该寻找什么在示例/教程方面,如果我想创建一个单独的类并在其中包含数据集?
Thanks for the reply, so you are suggesting I should have the dataset in a different class altogether and then be able to access the class from both windows? I am not a big fan of the single window approach since I like to be able to use multiple monitors to deal with the data and have the option of arranging them properly.
Basically this program will be used for plotting data and doing calculations on it. thus I would need a window with data, a window with graphs, etc.
Do you think a good solution would be to have an sql database behind the program? i.e. import data save it to a datatable inside a dataset and push it back to the sql database and then use that to deal with the data in other windows?
Would you have any ideas what i should look for in terms of examples/tutorials if I wanted to create a seperate class and have the dataset in in it?


这篇关于一个数据集2 wpf windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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