Reputation: 4727
Suppose we have the following code:
void App_Startup(object sender, StartupEventArgs args)
{
MessageBox.Show("something");
}
which is called when the App starts:
<Application x:Class="AppClass.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="App_Startup"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
When I run it without SplashScreen
, it runs as expected (i.e. waits for clicking OK
), however when running together with SplashScreen
, the message box disappears together with SplashScreen
.
Is it a normal behavior or a bug?
Upvotes: 0
Views: 714
Reputation: 8902
Try this,
Second parameter of SplashScreen Show(false, false
) method is to specify whether splashscreen should be top most.
void App_Startup(object sender, StartupEventArgs args)
{
SplashScreen screen = new SplashScreen("SplashImage.png");
screen.Show(false, false);
MessageBox.Show("something");
splashScreen.Close(TimeSpan.FromSeconds(1));
}
Upvotes: 2
Reputation: 7117
This will happen if you display a MessageBox and don't explicitly set the parent. The window will implicitly parent itself off whatever window is currently active (in this case, the splash screen). In the Win32 world if you close a window then all child windows will also be closed. If you explicitly set the MessageBox's parent to another window then you'll be fine.
This has been reported to microsoft here and possible remedies have been discussed here.
Upvotes: 3