0
我試圖挽救一個簡單的應用程序設置(「LanguagePairId」)是這樣的:爲什麼我的應用程序設置不被保留?
if (rdbtnEnglishPersian.IsChecked == true) // because "IsChecked" is a nullable bool, the "== true" is 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被分配的預期值(如果rdbtnEnglishSpanish檢查,它被分配3等)
但試圖讀取應用程序啓動時的程序設定值:
int langPairId;
public MainWindow()
{
InitializeComponent();
RecheckTheLastSelectedRadBtn();
}
private void RecheckTheLastSelectedRadBtn()
{
langPairId = AppSettings.Default.LanguagePairId;
switch (langPairId)
{
case 1:
rdbtnEnglishPersian.IsChecked = true;
break;
. . .
...失敗 - AppSettings.Default.LanguagePairId被視爲0上restaring應用。爲什麼?我必須做些什麼才能使價值得到保存和恢復?