Custom splash screen page for Windows Phone applications
This article explains how to create your own custom splash screen
In most cases during the launch of an application, you need to do some background operations such as making web request, parsing some data or something else and while doing this in background it is necessary to keep the user engaged by showing splash screen. This article helps you to achieve the same functionality.
- First create windows phone project from visual studio.
- Delete default splash screen image from project
- Your project already contains MainPage.xaml file keep it as it is, add new Page named SplashPage.xaml in project, replace existing xaml file code with following code.
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Image Source="/splash.jpg" Stretch="Fill"/>
Note keet SystemTray.IsVisible= False to show splash image covering whole screen.
Now open SplashPage.cs file
- Handle Loaded Event of SplashPage, refer following code
public partial class SplashPage : PhoneApplicationPage
private HttpWebRequest request;
Loaded += SplashPage_Loaded;
void SplashPage_Loaded(object sender, RoutedEventArgs e)
request = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://www.developer.nokia.com/Community/Wiki/Portal:Windows_Phone_UI_Articles"));
request.BeginGetResponse(new AsyncCallback(ReceiveResponseCallBack), null);
private void ReceiveResponseCallBack(IAsyncResult result)
HttpWebResponse response = (HttpWebResponse)this.request.EndGetResponse(result);
using (var stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
string str = reader.ReadToEnd();
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
Please note that SplashPage_Loaded function merely makes an asynchronous http request, and ReceiveResponseCallBack is called when http request returns response. On receiving the response, user is navigated to MainPage.xaml. deployment.Current.Dispatcher.BeginInvoke is used to access UI thread. In this file, you may perform any necessary background tasks while the splash screen is visible.
Modify MainPage.xaml.cs From SplashPage user is navigated to MainPage, Once MainPage is loaded remove stack entry of SplashPage from back stack as SplashScreen cant be consider as page so user doesn't want to come to SplashScreen,refer following code to do this
public partial class MainPage : PhoneApplicationPage
Loaded += MainPage_Loaded;
void MainPage_Loaded(object sender, RoutedEventArgs e)
Finally add SplashPage.xaml in WMAppManifest in Navigation Page tab so user is navigated to the Splash screen on application startup