简体   繁体   English

C#存储应用程序,在“基本”页面后退按钮上发送参数

[英]C# store app, send parameters on Basic page back button

I made a C# Store app. 我做了一个C#商店应用。 I send parameters to a page and read them, this all works fine. 我将参数发送到页面并读取它们,一切正常。 I send the parameters to other pages like this: 我将参数发送到其他页面,如下所示:

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

I make use of the basic pages (because it has a default backbutton and title. Now i want to send the parameter that i sended to the ItemDetailPage (like i did in above example) back in the page i am currently on, perhaps in the back button? 我使用基本页面(因为它具有默认的后退按钮和标题。现在,我想将发送到ItemDetailPage的参数(如上例中所做的那样)发送回我当前所在的页面中,也许是在返回键?

does anyone has a solution how i can save/ retreive de value when i return to this current page? 没有人有解决方案,当我返回当前页面时如何保存/恢复值?

thanks in advance. 提前致谢。

There are two ways to perform this: 1) Store the value in IsolatedStorageSettings object which is define in app.xaml.cs and store value in this and retrive in your desired pages. 有两种方法可以执行此操作:1)将值存储在app.xaml.cs中定义的IsolatedStorageSettings对象中,然后在其中存储值并在所需的页面中检索。 Example : 范例:

 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) decalre variable in app.xaml.cs and access it anywhere. 2)将app.xaml.cs中的decalre变量并在任何位置访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM