Tips And Tricks On Splash Screen In Silverlight Application

As you know we can visualize and customize Splash screen for a silverlight application. When the loading of silverlight application takes more than 500 millisecond, by default silverlight shows a splash screen of blinking circles and progress percentage. But have you ever seen a splash screen for small application(taking less than 500 milliseconds)? Do you have the curiosity to check for small application?

Please try out like this.

In App.xaml.cs file comment out initialization of RootVisual property like this:

privatevoid Application_Startup(object sender, StartupEventArgs e) {

//this.RootVisual = new MainPage();

}

Now silverlight application start-up page will not appear and you will see only the progress percentage as 100% in splash screen. So here only you can only check the splash screen by downloading .xap file. Now lets check out how to customize that splash screen.

Customizing Splash Screen:

Here we need a new xaml file lets say SplashScreen.xaml. This must be the part of web project (e.g: SilverlightApplication.web). This file is not included under SilverlightApplication.xap file because this needs to be shown when the .xap file is in the process of downloading.

1:  Right click on SilverlightApplication.web → Add –>New Item.

Then choose Silverlight1.0JscriptPage under silverlight template. Name it as  SplashScreen.xaml. Add those particular elements and style you want to show. Visual studio  assumes it as a basic Silverlight1.0 application.

**Note: Do not use elements that are defined by add-ons. Ex: under System.Windows.Controls.dll assembly because these are packaged under .xap.

2:  Define a javascript function in HTML entry page(SilverlightApplicationTestPage.html) or  ASP.NET test page(SilverlightApplicationTestPage.aspx). This function will format elements  by accessing it through sender.findName() and eventArgs. Progress to show the progress  percentage.

function onSourceDownloadProgressChanged(sender, eventArgs)

{

//Customize progress

}

3:  Now we need to identify the newly created splash screen and to call the javascript  method. So in object tag just add splashscreensource parameter to refer Splashscreen.xaml  page and onsourcedownloadprogresschanged parameter to call javascript method Like:

We will get a new custom splash screen now. Is it not interesting?

150 150 Burnignorance | Where Minds Meet And Sparks Fly!