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
Post a Comment