问题描述
我正在构建一个 Windows 手机应用程序,我需要一个设置页面.我想出了如何设置设置,但现在我需要知道如何从主页读取它们.
I'm building a windows phone app, and I need a settings page. I figured out how to set the settings but now I need to know how to read them from the main page.
所以从 MainPage.xaml.cs 我需要检查 ExitAlert 在 Settings.cs 上是真还是假,但我不知道怎么做.我确定这很简单.
So from MainPage.xaml.cs I need to check if ExitAlert is true or false on Settings.cs, and I can't figure out how. I'm sure it's something simple.
谢谢.
推荐答案
通常在 windows 中临时设置(对于特定实例)都存储在PhoneApplicationService.Current.State"中永久设置将存储在System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings"
Normally in windows temporary settings (For particular instance) are stored in the "PhoneApplicationService.Current.State" and the Permanent settings will be stored in the "System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings"
根据您的查询
您可以将值存储在设置页面中,如下所示
you can store the value in the settings page as follows
if(PhoneApplicationService.Current.State.Contains("ExitAlert"))
PhoneApplicationService.Current.State["ExitAlert"] = value;
else
PhoneApplicationService.Current.State.Add("ExitAlert", value);
您可以从主页访问该值,如下所示
and you can access the value from the main page as follows
if(PhoneApplicationService.Current.State.Contains("ExitAlert"))
value = (bool)PhoneApplicationService.Current.State["ExitAlert"];
if(value == true)
Messagebox.Show("Exit alert is set");
希望它能解决您的问题.
Hope it solve your issue.
这篇关于读取另一页上的变量集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!