c# - wp8 Application object -


i new windows phone programming , building wp8 application , access "app" object module eg:

modulea = 'public partial class app : application' object lives

moduleb = 'dothis.xaml' page lives

i have in modulea:

public partial class app : application {  // .. application stuff stripped out brevity    private void application_launching(object sender, launchingeventargs e)   {     // refresh value of istrial property when application launched     determineistrial();      string uristring = "/moduleb;component/dothis.xaml";     navigationservice.navigate(new uri(uristring, urikind.relative));   }  #region trial public static bool istrial {   get;   // setting istrial property outside not allowed   private set; }  private void determineistrial() { #if trial   // set true if trial enabled (debug_trial configuration active)   istrial = true; #else   var license = new microsoft.phone.marketplace.licenseinformation();   istrial = license.istrial(); #endif  #if debug   // set false if debugging....   //istrial = false; #endif  }  #endregion } 

i don't know how "app" object modulea on moduleb can access it

i in moduleb

protected override void onnavigatedto(system.windows.navigation.navigationeventargs e) {   debug.writeline("dothis- onnavigatedto");    if( app.istrial )  // modulea's "app" object   {      // disable functionality because trial mode...   }   // rest cut brevity  } 

thanks !

you can access application object via application.current.

declare interface in module class:

public interface imyapplication {     void dostuffinmainapp();            } 

and implement in application class:

public partial class app : application, moduleb.imyapplication {     ... } 

now can call method in application class module:

((imyapplication)application.current).dostuffinmainapp(); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -