I have two "MainWIndows". A Login screen and the actual Content Main Window. This is the process in which i want to happen.
User starts application
Clicks Login Button on the Login Window
Initialize the Content Window
Wait until all my lists and Data have been gathered, parse, and added to ListViews
Close the Login Window and show the Main Window. (Make MainWindow the main Window)
I am having issues actually hiding the main window, but i still need to be able to initialize it so i can gather all my data.
I added this to my App.xaml:
<Application.MainWindow> <NavigationWindow Source="MainWindow.xaml" Visibility="Hidden"></NavigationWindow> </Application.MainWindow> Here is my some of my LoginWindow code:
// Login complete, load the MainWindow Data MainWindow mainWindow = new MainWindow(); mainWindow.setLoginWindow = this; mainWindow.InitializeComponent(); //mainWindow.Show(); And the code i am using in the MainWindow:
public partial class MainWindow : MetroWindow {
Window LoginWindow; public Window setLoginWindow { get { return LoginWindow; } set { LoginWindow = value; } } public MainWindow() { InitializeComponent(); // Hide the window to load Data, then on completion, close LoginWindow and show MainWindow: ::: LoginWindow.Close(); LoadData(); } public void LoadData() { // Add player's to list .... // Done loading data, show the window LoginWindow.Close(); this.Visibility = Visibility.Visible; } }
The Question
How would i do this properly? Also, i want to keep the Focus on the LoginWindow until the MainWIndow has been shown.