Windows Phone 8.1 应用程序中的本地设置未存储

Local settings in Windows Phone 8.1 app are not stored

我为 Windows Phone 7 和 8 创建了许多应用程序。为了存储设置,我使用了这些方法:

IsolatedStorageSettings.ApplicationSettings["key"] = value;
IsolatedStorageSettings.ApplicationSettings.Save();

一切正常,我的设置已存储。 Save() 方法完成了工作。

但现在我正在为 Windows Phone 8.1 (WinRT) 创建一个应用程序。我已经跟着this guide学热保存设置了。这是现在的样子:

Windows.Storage.ApplicationData.Current.LocalSettings.Values["key"] = value;

但是当我关闭应用程序并再次 运行 时,它们就消失了,我的设置没有被存储。所以我的问题是:如何在 Windows Phone 8.1 中 保存 设置?

这条线确实有效:

 Windows.Storage.ApplicationData.Current.LocalSettings.Values["key"] = value;

问题是当您尝试通过在 XAML 中将其绑定为 属性 来调用它时。那么你可能会遇到问题。避免它,并在显式后面的代码中调用此方法。