c# - Why is my app setting not being retained? -
i'm trying save simple app setting ("languagepairid") way:
if (rdbtnenglishpersian.ischecked == true) // because "ischecked" nullable bool, "== true" necessary { langpairid = 1; } else if (rdbtnenglishgerman.ischecked == true) { langpairid = 2; } else if (rdbtnenglishspanish.ischecked == true) { langpairid = 3; } else if (rdbtngermanspanish.ischecked == true) { langpairid = 4; } else if (rdbtngermanpersian.ischecked == true) { langpairid = 5; } else if (rdbtnspanishpersian.ischecked == true) { langpairid = 6; } appsettings.default.languagepairid = langpairid;
languagepairid being assigned expected value (if rdbtnenglishspanish checked, assigned 3, etc.)
but trying read app setting value on app startup:
int langpairid; public mainwindow() { initializecomponent(); recheckthelastselectedradbtn(); } private void recheckthelastselectedradbtn() { langpairid = appsettings.default.languagepairid; switch (langpairid) { case 1: rdbtnenglishpersian.ischecked = true; break; . . .
...fails -- appsettings.default.languagepairid seen 0 on restaring app. why? must value saved , restored?
i don't see call appsettings.default.save()
anywhere.
without that, changes settings won't saved.
try adding after set property. e.g.:
appsettings.default.languagepairid = langpairid; appsettings.default.save();
Comments
Post a Comment