Click here to Skip to main content
15,886,703 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

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
 
Share this answer
 
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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900