0

我收集了用户输入,gotoWeb.xaml.cs并将收集到的输入存储在独立存储中。我需要将该存储的变量传递给MainPage.xmal.cs. 我不知道该怎么做?

我需要这个var Page1var Page2在 MainPage.xaml 中。这该怎么做 ?

代码在gotoWeb.xaml

IsolatedStorageSettings.ApplicationSettings["Page1"] = site;
IsolatedStorageSettings.ApplicationSettings.Save();
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
//store it in the settings 
if (!settings.Contains("qsPage1"))
{
//if setting has not been created, add it
settings.Add("qsPage1", site);
}
else
{
//store a the page in the setting
settings["qsPage1"] = site;
}
var Page1 = IsolatedStorageSettings.ApplicationSettings["qsPage1"];
// and by using same isolated settings method, created one more varible
var Page2 = IsolatedStorageSettings.ApplicationSettings["qsPage2"];
4

3 回答 3

0

您可以查看 Messenger for MVVM Pattern。您可以传递所有内容,并且很容易实现。

于 2013-08-30T12:02:15.807 回答
0

当您使用 ApplicationSettings 时,即使退出应用程序,数据也会保留。如果这是您想要的,并且如果您在应用程序重新启动后进入 MainPage 时也要加载此数据,则只需覆盖 MainPage 的 OnNavigatedTo 以从 ApplicationSettings 加载数据。

于 2013-08-30T12:06:33.613 回答
-1

非常快速和肮脏:

page1.xml:
public class values
    {
        public static var value1 = 123;
        public static var value2 = 234;
        public static var value3 = 345;


    }

 page2.xml:

 var localvalue1 = page1.values.value1;
 var localvalue2 = page1.values.value2;
 var localvalue3 = page1.values.value3;
于 2013-08-30T20:19:48.310 回答