Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows应用商店应用中的SaveState和LoadState_C#_Xaml_Windows 8_Windows Store Apps - Fatal编程技术网

C# Windows应用商店应用中的SaveState和LoadState

C# Windows应用商店应用中的SaveState和LoadState,c#,xaml,windows-8,windows-store-apps,C#,Xaml,Windows 8,Windows Store Apps,VisualStudio的默认模板中非常好的一件事是LayoutWarePage。我们可以在应用程序导航和终止中保存页面的状态和加载状态。在本例中,我在根网格中有n个组合框和文本框 导航到下一页时,我使用以下代码保存根网格的状态 pageState.Add("RootGridPage",RootGrid); if (pageState !=null && pageState.ContainsKey("RootGridPage")) {

VisualStudio的默认模板中非常好的一件事是LayoutWarePage。我们可以在应用程序导航和终止中保存页面的状态和加载状态。在本例中,我在根网格中有n个组合框和文本框

导航到下一页时,我使用以下代码保存根网格的状态

pageState.Add("RootGridPage",RootGrid);
if (pageState !=null && pageState.ContainsKey("RootGridPage"))
            {
                RootGrid= pageState["RootGridPage"] as Grid;
            }
我根据猜测编写了代码,LayoutWarePage将负责根网格中所有可用控件的序列化,而不是只序列化根网格

当我尝试使用以下代码在LoadState方法中获取根网格时

pageState.Add("RootGridPage",RootGrid);
if (pageState !=null && pageState.ContainsKey("RootGridPage"))
            {
                RootGrid= pageState["RootGridPage"] as Grid;
            }
我没有在根网格中获得反序列化的组合框和文本框。它并没有持续到这个状态。我的问题是,如果我们保存根网格的状态,它是否会保存其中控件的所有可用状态?。如果不是,有没有办法做到这一点?。因为我无法保存所有“n”个控件的状态。
您能在这方面帮助我吗?

需要将网格绑定到视图模型。视图模型中属于会话状态的所有属性都可以添加到load/savestate方法中的pageState