0

In my app, first page(page1) shows the list of items, when an item is selected, i will pass the name to another page(page2) and with that name will get the data from the server.And all the data will be显示。在详细信息中,其中一个是类别(杂货、化妆品等),所以如果我单击该文本框,它将导航到另一个页面(page3),您可以在其中选择另一个类别,在选择另一个类别后,它的名称将再次被传递返回详情页(Page2)。在我的第二页中,我将使用以下代码获取数据,

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Uri.OriginalString.Contains("name"))
{
    var ItemName = NavigationContext.QueryString["id"];          
    //this is a parameter from page1 
    // do something
}
else   if (e.Uri.OriginalString.Contains("category"))
{
    var CategoryName= NavigationContext.QueryString["category"];          
    //this is a parameter from page3 
    // do something
}
}

但是当我从第 3 页回到第 2 页时,发现我显示的所有详细信息(通过从第 1 页获取名称)都丢失了。我怎样才能保留这些数据?

4

1 回答 1

0

这些是在 windows phone 中的页面之间导航时传递数据的可能方法

  1. 使用独立存储在 Windows Phone 7 上存储数据
  2. 通过页面之间的参数传递数据
  3. 动态生成数据网格,其中包含数据和相关链接按钮
  4. 使用 XElement、XAttribute 作为数据结构

参考请看这里

于 2013-10-24T05:39:18.893 回答