【发布时间】:2013-07-13 08:43:21
【问题描述】:
如何让我的代码直接从 Windows Phone 的页面设置中设置和获取设置?
if (IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] == true)
return;
else
{
MessageBoxResult result =
MessageBox.Show("Can I use your position?",
"Location",
MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = true;
}
else
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = false;
}
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
else
{
MessageBoxResult result =
MessageBox.Show("Can I use your position?",
"Location",
MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = true;
}else
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = false;
}
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
在此示例中,我使用位置设置,然后我意识到当我从应用程序中将其设置为 true 时,页面设置中的设置也会更改为 on。但是当我将我的位置设置从原始 Windows Phone 中的页面设置更改为关闭时,但在我的应用程序中它仍然显示为 true。如何解决这个问题?
【问题讨论】:
标签: c# windows-phone-8 application-settings