I try to implement Splash Screnn in WPF. I have found some nice ehample in MSDN, but there is one place:
private void _applicationInitialize(SplashScreen splashWindow)
{
Thread.Sleep(1000);
// Create the main window, but on the UI thread.
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Invoker)delegate
{
Window1 MainWindow = new Window1();
Helper.setWin(MainWindow);
MainWindow.Show();
});
}
The problem is Helper, whats the class is there and how it must be implemented. Someone could paste an example or smth?
There is an even easier way:
http://msdn.microsoft.com/en-us/library/cc656886.aspx
- Add the image file to the WPF Application project. For more information, see How to: Add Existing Items to a Project.
- In Solution Explorer, select the image.
- In the Properties window, click the drop-down arrow for the Build Action property.
- Select SplashScreen from the drop-down list
You can use code like this do display an image on startup:
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml" Startup="Application_Startup">
in the code behind:
private void Application_Startup(object sender, StartupEventArgs e)
{
SplashScreen screen = new SplashScreen("Images/splash.bmp");
screen.Show(true);
}
来源:https://stackoverflow.com/questions/1741922/wpf-splashscreen-implementing