不存储 Windows Phone 8.1 应用程序中的本地设置 [英] Local settings in Windows Phone 8.1 app are not stored
问题描述
我为 Windows Phone 7 和 8 创建了许多应用程序.为了存储设置,我使用了以下方法:
I have created many apps for Windows Phone 7 and 8. To store settings I was using these methods:
IsolatedStorageSettings.ApplicationSettings["key"] = value;
IsolatedStorageSettings.ApplicationSettings.Save();
一切正常,我的设置已存储.Save()
方法完成了这项工作.
Everything worked perfectly, my settings were stored. Save()
method did the job.
但现在我正在为 Windows Phone 8.1 (WinRT) 创建一个应用程序.我已按照本指南学习热保存设置.这是现在的样子:
But now I am creating an app for Windows Phone 8.1 (WinRT). I have followed this guide to learn hot to save settings. Ane here is how it looks like now:
Windows.Storage.ApplicationData.Current.LocalSettings.Values["key"] = value;
但是当我关闭应用程序并再次运行时,它们消失了,我的设置没有存储.所以我的问题是:如何在 Windows Phone 8.1 中保存设置?
But when I close the app and run again, they're gone, my settings are not stored. So my question is: How to save settings in Windows Phone 8.1?
推荐答案
这行确实有效:
Windows.Storage.ApplicationData.Current.LocalSettings.Values["key"] = value;
问题是当您尝试通过 XAML 中的绑定作为属性调用它时.那么你可能会遇到问题.避免它,并在显式背后的代码中调用此方法.
The problem is when you're trying to call it via binding in XAML as a property. Then you may have problem with it. Just avoid it, and call this method in code behind explicite.
这篇关于不存储 Windows Phone 8.1 应用程序中的本地设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!