Click here to Skip to main content
13,050,358 members (139,833 online)
Rate this:
Please Sign up or sign in to vote.
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).

Posted 7-Jun-13 4:48am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100