21

我只是想知道您如何处理 Windows Phone 8.1 SDK 中的 IsolatedStorageSettings。例如:

IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent")

这在 8.1 中如何工作?如,我如何编写此语句而不会出现上下文错误。我觉得它已被弃用或其他什么,因为它不能解析为已知的命名空间或任何东西。

我正在为我当前的项目使用地图并将其移植到 8.1 给我带来了一些语法问题。我已经尝试过查找它,但我认为现在查找文档还为时过早,因为 MSDN 甚至没有说明它,除非我不小心错过了它。任何帮助表示赞赏。

4

1 回答 1

45

使用 Windows.Storage 命名空间中的类。它们是通用应用程序的新功能。如果您希望数据始终保持在本地,请尝试Windows.Storage.ApplicationData.Current.LocalSettings。但是,如果您不介意它们存储在漫游设置中(如果您使用通用应用程序,它们将可用于 Windows 8.1 中的应用程序),您可以使用Windows.Storage.ApplicationData.Current.RoamingSettings

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if(localSettings.Values.ContainsKey("LocationConsent"))
   DoSomething(localSettings.Values["LocationConsent"])

或者

var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
if(roamingSettings.Values.ContainsKey("LocationConsent"))
   DoSomething(roamingSettings.Values["LocationConsent"])

这应该可以解决您的问题。我从头顶写了这个,希望它对你有用。

于 2014-04-16T23:20:53.383 回答