How to create a Splash Screen on Windows Phone

Asked

Viewed 750 times

1

How do I create a Splash Screen in my app?

I would like examples!

1 answer

5


See this article How to create an opening screen for Windows Phone(Msdn - English).

Free Translation:

If you are using a single image, you should add an image file that is 768×1280 nominee SplashScreenImage.jpg for your project. Your phone automatically resizes the image to the correct size. If you want to provide initial screens of pixel-Perfect for all resolutions, you can add the following images to the root folder of your application project.

WVGA 480×800   SplashScreenImage.screen-WVGA.jpg
WXGA 768×1,280 SplashScreenImage.screen-WXGA.jpg
720p 720x1,280 SplashScreenImage.screen-720p.jpg 

Each new project Windows Phone OS 7.1 includes a file Splashscreenimage.jpg. To customize the home screen, you can replace your own image to the default image. You can replace the default image with any image you choose, but it should be 480×800 pixels of size, and it should be named Splashscreenimage.jpg. You must define the property Build Action from image to content.

Example

Here(Nokia Developer) there is an example that may be useful to you.

First create a project with Windows Phone App Template. Create a Windows Phone User Control add a ProgressBar, TextBlock and a Image. The image is the default splash of the project.

<Grid x:Name="LayoutRoot" Background="White" Width="480" Height="800">            
<ProgressBar HorizontalAlignment="Left" Margin="47,692,0,89" Name="progressBar1" Width="383"  />  
<Image Height="512" HorizontalAlignment="Left" Margin="0,0,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="480" Source="SplashScreenImage.jpg" />            
<TextBlock HorizontalAlignment="Left" Margin="185,656,0,114" Name="textBlock1" Text="Please Wait..." Width="111" Foreground="Black" FontSize="22" />        
</Grid>

In the builder Mainpage.xaml.Cs we call the function ShowSplash() to load the popup.

private void ShowSplash()
        {
            this.popup = new Popup();
            this.popup.Child = new SplashScreenControl();
            this.popup.IsOpen = true;
            StartLoadingData();
        }

We will initialize the class Popup and then set the class SplashScreenControl to be hosted in the popup. IsOpen() opens the pop-up.

So far the code will load the home screen (pop-up) with the progress bar.

Now let’s add some background process, and when the background process is completed, we will close the pop-up as a result, the user will see the home screen. The function StartLoadingData() starts and completes the background work.

private void StartLoadingData()
        {
            backroungWorker = new BackgroundWorker();
            backroungWorker.DoWork += new DoWorkEventHandler(backroungWorker_DoWork);
            backroungWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backroungWorker_RunWorkerCompleted);
            backroungWorker.RunWorkerAsync();
        }

First let’s initialize the class BackgroundWorker. We call the function RunWorkerAsync() to initiate the implementation of a fund operation and thus, backroungWorker_DoWork() is called.

void backroungWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //here we can load data
            Thread.Sleep(9000);
        }

Here we use the function Sleep() to wait for some time. When backroungWorker_DoWork() expires, backroungWorker_RunWorkerCompleted() is called, which closes the pop-up.

void backroungWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                this.popup.IsOpen = false;
            }
            );
        }

So the user can see a screen with the progress bar.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.