I would like to add some king of splash screen (modal) window in the "OnLauched" method of my WinUI 3 application.
Currently I just instanciate my main window, which is of type 'NavigationRootWindow', as you can see here:
protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
// Display splash screen with database check and user login
// If all is well: Proceed normally
// If database not available or login failed: Abort with application start / close application
// Display NavigationRootWindow (main window of the application)
NavigationRootWindow navigationRootWindow = new NavigationRootWindow();
m_window = navigationRootWindow;
m_window.Activate();
}
Before I do that, I would like to do two things (see comments in the first part of the method):
- Check if the database connection is available.
- Login the user
This I would like to do in a separate window with a view model and the logic that performs the checks. I am sure I can implement the window with the view model and its logic.
However I am simply not able to display any kind of window / splash screen before I instanciate the 'NavigationRootWindow'. If the login is sucessful, I would need to close the splash screen / login window again, before I instanciate the 'NavigationRootWindow'. As I understand, I cannot instanciate another 'Window' derived type, because there is only one application window.
Can you suggest an approach to display a splash screen / some modal dialog triggered from within the "OnLaunched" method? The result of this screen shall determine if the application can continue. I am also open for other suggestions.
Thank you.