0
votes

Page Navigation in Windows Phone 8.1 is:

Frame.Navigate(typeof(SecondPage));

or with parameter:

Frame.Navigate(typeof(SecondPage), param);

and on the target page:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
  myTextBox.Text = e.Parameter.ToString();
}

or

protected override void OnNavigatedTo(NavigationEventArgs e)
{
  var val = (myClass)e.Parameter;
  myTextBox.Text = val.Text;
}

But in my case I want to do something with those data received on the target page. For example I want to let the user edit those data and save them as new data. I've searched for hours and all I could find was just page navigation with or without parameter and not the one I've described above. Is there any way to approach this? Any suggestion, solution is appreciated!

1
When you say "edit", what do you want to do with the edited version? Pass it back to the caller? Save to a web service?Rowland Shaw
As I've said above save the new data locally in the ApplicationData.Current.LocalSettingsShaheem John
@ShaheemJohn Where is your problem? Just save it to the local settings. msdn.microsoft.com/en-us/library/windows/apps/xaml/…cansik
Yes all I want to do with the received data on the target page is to save them locally in the ApplicationData.Current.LocalSettings that is it.Shaheem John
@cansik The link you've sent it do not explain my scenario.Shaheem John

1 Answers

1
votes

To pass your text and the settings name to your edit form, use a KeyValuePair:

//figure out how to get the text out of the list
var myItem = new KeyValuePair<string, string>("mytextsetting", "listbox.selecteditem.text");
Frame.Navigate(typeof(SecondPage), myItem);

On the second page, you can now store the incoming parameter:

KeyValuePair<string, string> _myItem;

protected override void OnNavigatedTo(NavigationEventArgs e)
{
   _myItem = e.Parameter as KeyValuePair<string, string>;
   myTextBox.Text = myItem.Value;
}

Now when the user wants to save the edited text:

_myItem.Value = myTextBox.Text;

//save it to the settings
localSettings.Values[_myItem.Key] = _myItem.Value;