Custom splash screen page for Windows Phone applications
m (Croozeus - Corrected Icode template, added header)
m (Croozeus - spilt into new section)
|Line 139:||Line 139:|
The last step is to add SplashPage.xaml in the Navigation Page tab of WMAppManifest
The last step is to add SplashPage.xaml in the Navigation Page tab of WMAppManifestso user is shown the splash screen when the application is launched.
Revision as of 08:48, 7 November 2012
This article explains how to create a custom splash screen for your Windows Phone application.
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 create this splash screen.
- First create a Windows phone Project in visual studio.
- Delete default splash screen image from project.
- Your project already contains MainPage.xaml file, keep it as it is. Add a new Page named SplashPage.xaml in the project, replace the 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"/>
Make sure to set shell:SystemTray.IsVisible to False for using the full screen to display the image.
Now, edit SplashPage.cs file
- Handle the Loaded Event of SplashPage - SplashPage_Loaded, as shown below,
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 the HTTP request returns a response. On receiving a response, the user is navigated to MainPage.xaml. deployment.Current.Dispatcher.BeginInvoke is used to access UI thread. Thus in the function, you may add code to perform any necessary background tasks while the splash screen is shown to the user.
From SplashPage the user is navigated to MainPage. Once the MainPage is loaded we should remove the stack entry of the SplashPage from back stack. This is done so that SplashScreen isn't considered as a page and the user doesn't navigate back to it by using the back key. To do this we need to modify the file MainPage.xaml.cs as follows.
public partial class MainPage : PhoneApplicationPage
Loaded += MainPage_Loaded;
void MainPage_Loaded(object sender, RoutedEventArgs e)
The last step is to add SplashPage.xaml in the Navigation Page tab of WMAppManifest.xml file. This is done so that the user is shown the splash screen when the application is launched.