Categories: C# Programming

Creating Splash Screen in Windows Phone 8.1 Silverlight applications

Hello people!
I hope everyone would be doing amazing.

So, I have been looking around to see if there was anyway I could use the default Splash Screen for Windows Phone 8.1 Silverlight application, just like the normal Windows Phone 8.1 application template has a default, but I couldn’t because there isn’t any that comes with the project template (if there is a way you know do let me know).

Let’s start with making an empty project for Windows Phone 8.1 Silverlight.

Open your Solution Explorer and right click your project and select Add then click New item, following window will appear.

Select Windows Phone User Control, name it as SplashScreen.xaml or whatever you like then click Add. You’ll be navigated to this page.

Resize your User Control to match the dimensions of your MainPage.xaml. Drag and Drop a TextBlock on your User Control and edit it with your app name.

Open up the MainPage.xaml.cs file of your project

.
Inside your MainPage.xaml.cs class create two objects.

BackgroundWorker BackgroundWork;
Popup pop;

You’ll also need to add these namespaces in your project.

using System.ComponentModel;
using System.Windows.Controls.Primitives;
using System.Threading;

Then inside your MainPage Constructor add the following code.

pop = new Popup();
pop.IsOpen = true;
//Here goes the name of your User Control in our case it was SplashScreen
pop.Child = new SplashScreen();
//Then finally start the Process
StartProcess();

The implementation of the StartProcess function that will be handling all the delay and hiding of the User Control for us, goes this way.

private void StartProcess()
{

BackgroundWork = new BackgroundWorker();
BackgroundWork.RunWorkerCompleted += ((r, args) => { this.Dispatcher.BeginInvoke(() => { this.pop.IsOpen = false; }); });
//Set the time for how long you want the Splash Screen to stay appeared
BackgroundWork.DoWork += ((r, args) => { Thread.Sleep(5000); });
BackgroundWork.RunWorkerAsync();

}

Finally, Run and test your app. You would see the following screen staying for some seconds.

That’s it for this tutorial. You can download this project from Github.
Good day!

Aaqib Hussain

Share
Published by
Aaqib Hussain

Recent Posts

Things to know when moving to Germany

This article covers some important things you must know when you are considering a move…

3 years ago

Unit Testing in Android for Dummies

What is Unit Testing? In its simplest term, unit testing is testing a small piece…

4 years ago

Factory Design Pattern

In this article, you will learn about a type of Creational Design Pattern which is…

5 years ago

Creating Target specific Theme in iOS

In this tutorial, you will go through the use of targets to achieve two separate…

5 years ago

Facade Design Pattern

In this article, you will learn about a type of Structural Design Pattern which is…

5 years ago

Singleton Design Pattern

In this article you will learn about a type of Creational Design Pattern which is…

5 years ago