本文介绍了Windows Phone 8 ApplicationSettings - 在通用应用程序中获取设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在升级 Windows Phone 8 应用程序.我创建了通用应用(Windows.Phone 8.1).

I'm upgrading windows phone 8 application. I created Universal app (Windows.Phone 8.1).

旧版 WP8.0 应用中的设置保存方式如下:

The settings in old WP8.0 application are saved in following way:

IsolatedStorageSettings.ApplicationSettings.Add("MY_SETTINGS", value);

问题:当应用升级到 WP8.1(通用应用)时,我如何获得此设置.

Question:How can i get this settings when app is upgraded to WP8.1 (Universal app).

我尝试以下操作:

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
var isContains1 = localSettings.Values.ContainsKey("MY_SETTINGS");
var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
var isContains2 = roamingSettings.Values.ContainsKey("MY_SETTINGS");

但是没有找到MY_SETTINGS".(isContains1, isContains2 == false):\

But no "MY_SETTINGS" are found. (isContains1, isContains2 == false):\

非常感谢您的帮助

推荐答案

这篇博文有你的确切答案,包括反序列化迁移的设置文件所需的代码!

This blog post has your exact answer, including the code needed to deserialize the migrated settings file!

这篇关于Windows Phone 8 ApplicationSettings - 在通用应用程序中获取设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 00:03