Problem You want to build your own nice-looking Splash Screen in your Windows Phone 8 App.
SolutionEvery app should have a nice Loading Page at start.So, we'll building a nice one from scratch. Let's start!
The trick of having a Splash Screen is to display a UserControl as a Popup object. So make sure you add a new usercontrol with the following properties:UserControlHeight 800Width 480 GridHeight 800Width 480
You can fill in the Grid as you like, but I prefer adding a logo and ProgressBar with "IsIndeterminate" set to "True".A case you can think as a Splash Screen:
We have a label "Erdal Ozkaya" ,the logo of the app, a "Please Wait…" label and then a progressbar with the "IsIndeterminate" property set to "True".
private Popup popup; private BackgroundWorker backroungWorker;
private BackgroundWorker backroungWorker;
private void StartLoadingData() { backroungWorker = new BackgroundWorker(); backroungWorker.DoWork += new DoWorkEventHandler(backroungWorker_DoWork); backroungWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backroungWorker_RunWorkerCompleted); backroungWorker.RunWorkerAsync(); } void backroungWorker_DoWork(object sender, DoWorkEventArgs e) { Thread.Sleep(9000); }
{ backroungWorker = new BackgroundWorker(); backroungWorker.DoWork += new DoWorkEventHandler(backroungWorker_DoWork); backroungWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backroungWorker_RunWorkerCompleted); backroungWorker.RunWorkerAsync(); } void backroungWorker_DoWork(object sender, DoWorkEventArgs e) { Thread.Sleep(9000); }
void backroungWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this.Dispatcher.BeginInvoke(()=> { this.popup.IsOpen= false; } ); }
3. Create a method that displays Popup and load StartLoadingData method.
private void ShowSplash(){ this.popup = newPopup(); this.popup.Child = newSplashScreenControl(); this.popup.IsOpen =true; StartLoadingData();}
4. Finally add ShowSplash in your constructor.
public MainPage() { InitializeComponent(); ShowSplash(); }
That's it!Finally when you run the application, SplashScreen will appear 9 seconds then will be closed.
Have fun!
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: