I have the below code. The GetMode
method performs some operations that take some time to complete, for this reason, I want the startup window to show up and display a message and an animation while the main window loads inside the GetMode
method.
The startup window shows up but does not show any content, it stays blank and waits until the GetMode
finishes, shows the content for an instant, closes immediately and the main window shows up. I tried listening to the Activated
event but I got the same result, I tried listening to the Loaded
event of the content inside the startup window but got also the same result, if I await GetMode
I get an exception that doesn’t even have a message. In WPF, this is pretty straightforward with the Show
and Hide
methods in a window, but in WinUI3 it’s not that easy (of course not, silly me that expects it to be lol).
private Window _mainWindow;
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
var startupWindow = new StartupWindow();
startupWindow.Activate();
GetMode();
startupWindow.Close();
_mainWindow.Activate();
}
How can I achieve this? Thanks!