Thank you for your trouble r.singleton, I really appreciate it! Let me just begin by saying that I'm sorry for all the questions that I will ask you (bellow). I've read and re-read and re-re-read your post and StackOverFlow posts and still don't get it.
For starters, I don't understand the concept behind the singleton Window. Are you saying that, instead of opening/closing several windows, I should only have one window (the singleton) and update it accordingly?
For instance, according to your link I've added
public partial class MainWindow : Window
{
public static MainWindow Instance { get; private set; }
static MainWindow ()
{
Instance = new MainWindow ();
}
private MainWindow ()
{
//...
}
//...where I've added all the buttons and event raises
//Then, I have the Next button, that will close the MainWindow and open the SecondWindow
private void NextButton_Click(object sender, RoutedEventArgs e)
{
SecondWindow secondWindow = new SecondWindow();
Window window2 = new Window();
window2.Content = secondWindow.Content;
//And then I hide the window (current one) while I just opened the new one previously
var button = sender as System.Windows.Controls.Button;
var win = Window.GetWindow(button); win.Hide();
//Show the new window (i.e. Window:SecondWindow)
window2.Show();
}
}
But then, on the StackOverFlow it was also stated that I should add this:
public App()
{
...
Startup += App_Startup;
...
}
void App_Startup(object sender, StartupEventArgs e)
{
TestApp.MainWindow.Instance.Show();
}
The thing is that I don't have an Application but a Window instead, and the Window doesn't have the Startup function.
So how should I "transform" my MainWindow into a singleton? And how should I "replace" the buttons of the MainWindow with the buttons on the SecondWindow without actually closing the MainWindow? This might sound a little bit confused.
Basicaly, what I'm saying is how should I design my code in order to 1) Open MainWindow and use the buttons in it, 2) Click on button "Next" so that I will go to SecondWindow, and 3) On the SecondWindow I visualize other buttons and I can actually use them.
Thank you very very much!