0
votes

I am looking for a simple way to return data from a form. I am trying to populate a text box on form 1 with data returned from form 2. This is the code used to navigate to form 2:

this.Frame.Navigate(typeof(form 2));

And I know you can pass a parameter back to form 1 using this method, but when back is pressed it would go to form 2 which is not ideal as I want it to go back to form 0.

Can you return data using this or something similar:

 Frame.GoBack();

Additionally, are the only methods for transferring data between pages:

pass a handler to a previous Page, so you can access public variables/properties from current Page,

use a static variable/property - maybe a singleton

again use files/settings

As said in Passing Data from Page to Page for Windows Phone 8.1

1

1 Answers

1
votes

Is there a reason why you wouldn't want to use the option number 2 in the list you mentioned - storing it in a simple static property? That's certainly a quick solution.

One other option, if you are using MVVM and a library such as MVVM Light, would be to send the value from the ViewModel connected to form 2, to the ViewModel connected to form 1, using a messenger.

Subscribing:

Messenger.Default.Register<TypeOfMessageYouWantToSend>(this, MethodWhichHandlesTheReceivedValue);

And sending:

Messenger.Default.Send<TypeOfMessageYouWantToSend>(msg);

You can send it when navigating back, or even while the form is being populated etc.