WPF: Maintaining states by implementing tabs with navigation windows?

706 Views Asked by At

I'm making an application in C# WPF that consists of a top-root NavigationWindow with several pages that I navigate between for the purpose of the project. At this point, I want to extend the functionality of the application by adding in a second "state" of the program.

Here's how I'd like this to work: Essentially the program is a data collection application. At the moment it displays relevant UI information for database A and allows you to collect data for that one specifically. I want to expand the software by adding in a second set of UI elements that collect different data for database B, and I want to navigate between them using Tabs at the top (so using tabcontrol and tabitems).

The part that I'm stuck on is the maintaining states portion: For example, if I'm on the tab for database A, I can go through a date selection screen and to the actual collection screen, but if I click on the tab for database B, then it will still be back at the date selection screen since I have not done anything there yet (essentially like having 2 programs running at the same time, within each tab).

I tried seeing if I could change the root element of the software from a NavigationWindow to a Page that contains a NavigationWindow inside of tabitems (since only Page implements tabcontrol), but I have not figured out how to do this (if it can even be done). Is there a better way to go about doing this?

1

There are 1 best solutions below

0
On

There are two ways I see to do this:

  1. Keep the State information outside of the tab's Content. So items such as CurrentStep would be tracked at a higher level than the TabControl's content

  2. Or make a fake tab control. Switching tabs doesn't really change anything, instead it just changes a property in your ViewModel that determines the connection.

As a side note, why not consider a dropdown to specify the database instead of a tab control?