windows phone 8.1 - C# Accept button -


i building universal application windows phone 8.1.

i have setting page there 1 toggle switch. have tried find out how can save toggle switch state. after apps closed , again opened.

this how try:

private void button_click(object sender, routedeventargs e) {     isolatedstoragesettings settings = isolatedstoragesettings.applicationsettings;     if (!settings.contains(tswitch.ison))     {         settings.add(tswitch.ison);     }     settings.save();     this.frame.navigate(typeof(mainpage), null); } 

try this:

private void button_click(object sender, routedeventargs e) { if (tswitch.ison)         {             windows.storage.applicationdata.current.localsettings.values["tswitch"] = "set";             windows.storage.applicationdata.current.localsettings.values["tswitchvalue"] = "on";         }         else         {         windows.storage.applicationdata.current.localsettings.values["tswitch"] = "notset";         windows.storage.applicationdata.current.localsettings.values["tswitchvalue"] = "off";         } } 

then in app.xaml.cs, add:

        switch ((string)windows.storage.applicationdata.current.localsettings.values["tswitchvalue"])         {             case "set":                 {                  //do                    break;                 }            case "notset":                  {                 //do                break;                 }                            default:                 {                   //do                      break;                 }         } 

you can change case options per toggle switch requirements.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -