c# - How to Show a Page if Application is Launched for the First Time -


i wondering how signal whether appication launched first time, or has been launched before. reason want show short informative message before application ever used, while every other time application launched nothing shows. place in app.xaml.cs following

var settings = isolatedstoragesettings.applicationsettings; if (!settings.contains("waslaunched"))  {   messagebox.show("first time launch");   settings.add("waslaunched", true); } 

and if (!settings.contains("waslaunched") navigate 'first launch page' opposed 'main page'? can point me references on implementation?

edit**

i changed wmappmanifest.xml default page launchpage.xaml

<defaulttask name="_default" navigationpage="launchpage.xaml" /> 

and created urimapper class

public class loginurimapper : urimapperbase {     public override uri mapuri(uri uri)     {         if (uri.originalstring == "/launchpage.xaml")         {             if (settings.firstload.value == true)             {                 //navigate welcome page quick first time user info                 uri = new uri("/views/welcomepage.xaml", urikind.relative);             }             else             {                 ///navigate actual main page                 uri = new uri("/mainpage.xaml", urikind.relative);             }         }         return uri;     } } 

but how change app.xaml.cs accordingly

private void application_launching(object sender, launchingeventargs e) {     //how check , navigate correct page specific method? }  private void application_activated(object sender, activatedeventargs e) {     //how check , navigate correct page specific method? } 

you'd better use power of urimapper

here can find article.

the core idea is:

you should define empty page (entrypage.xaml) , set default page of app. in custom urimapper overload mapuri method.

   public class yoururimapper : urimapperbase    {     public override uri mapuri(uri uri)     {         if (uri.originalstring == "/entrypage.xaml")         {             var settings = isolatedstoragesettings.applicationsettings;              if (!settings.contains("waslaunched"))             {                  uri = new uri("/firstruninfopage.xaml", urikind.relative);             }             else             {                  uri = new uri("/mainpage.xaml", urikind.relative);              }          }             return uri;      }    } 

then on app initialization should define urimapper use:

private void application_launching(object sender, launchingeventargs e) {     rootframe.urimapper = new yoururimapper(); }  private void application_activated(object sender, activatedeventargs e) {     if (e.isapplicationinstancepreserved == false)     {       // tombstoned! need restore state       rootframe.urimapper = new yoururimapper();     } } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -