c# - Make onetime page Windows Phone 8 -
i making application in vs2012 windows phone 8, c#/xaml. now, want make page run when app installed , user opens app first time. not anytime after that.
kindly help, thanking you
you can use xml file write value says whether or not page has been displayed. in page's constructor (or more appropriately in it's onload event) can write value xml file , it's been displayed. in startup logic can read file , if value has been set, can skip different page.
xml file
<startupvalues> <hasfirsttimepagedisplayed>true</hasfirsttimepagedisplayed> </startupvalues>
page-you-want-to-show-once
xaml
<page loaded="onloaded" ... />
xaml.cs
public void onloaded( object sender, routedeventargs args ) { var xml = new xmlserializer( typeof( startupvalues ) ); using( var writer = new streamwriter( "config_file_path_here.xml" ) ) { xml.serialize( new startupvalues { hasfirsttimepagedisplayed = true }, writer.basestream ); } }
app.xaml.cs
public void onstartup( ... ) // forget method signature { bool displayfirstpage = true; var xml = new xmlserializer( typeof( startupvalues ) ); using( var reader= new streamreader( "config_file_path_here.xml" ) ) { startupvalues values = xml.deserialize( reader.basestream ) startupvalues; displayfirstpage = values.hasfirsttimepagedisplayed; } if( displayfirstpage ) { // display page } else { // display different page } }
startupobject.cs
public class startupvalues { public bool hasfirsttimepagedisplayed { get; set; } }
some reading material relating problem:
xmlserializer class
streamreader class
wp8 dev center (a great place resources)
Comments
Post a Comment