【问题标题】:I can't use IsolatedStorageSettings for windows phone 8.1我不能为 windows phone 8.1 使用隔离存储设置
【发布时间】:2014-07-05 01:17:10
【问题描述】:

添加时出现错误

IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;

在我的 MainPage.xaml.cs 中用于按钮单击事件。

错误:

  1. 找不到类型或命名空间名称“IsolatedStorageSettings”(是否缺少 using 指令或程序集引用?)

  2. 当前上下文中不存在名称“IsolatedStorageSettings”

我正在使用 Visual Studio Ultimate 2013(更新 2)。

请帮帮我

【问题讨论】:

标签: c# visual-studio-2013 windows-phone-8.1


【解决方案1】:

使用Windows.Storage 命名空间中的类。它们是通用应用程序(Windows Phone 8.1 和 Windows 8.1)的新功能。

如果您希望数据始终保持在本地,请尝试 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"))

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-18
  • 1970-01-01
相关资源
最近更新 更多