c#存储应用程序,在基本页面上发送参数返回按钮

本文关键字:参数 按钮 返回 应用程序 存储 | 更新日期: 2023-09-27 17:52:15

我制作了一个c# Store应用程序。我将参数发送到页面并读取它们,这一切都很好。我将参数发送到其他页面,像这样:

this.Frame.Navigate(typeof(ItemDetailPage), UniqueID); //(works)

我使用了基本页面(因为它有默认的后退按钮和标题)。现在我想发送的参数,我发送到ItemDetailPage(就像我在上面的例子)回到我目前在页面上,也许在后退按钮?

是否有人有一个解决方案,我如何可以保存/检索贬值,当我返回到这个当前页面?

c#存储应用程序,在基本页面上发送参数返回按钮

有两种方法:1)将值存储在isolatedstoragessettings对象中,该对象在app.xaml.cs中定义,并将值存储在此并在所需页面中检索。示例:

 public IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
  store value like this : 
  (App.Current as App).settings.Add("sampledata", txtsomething.Text);  
  for retrive : 
  (string)(App.Current as App).settings["sampledata"];
  and whenever you want to update the data just remove the value inside this and then add     again.

2)在app.xaml.cs中声明变量并在任何地方访问它。