I need to navigate from one xaml page to another with an Object not a String ..
present code is :
private void Border_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
{
string uri = "/PhonePageOne.xaml?Text=";
uri += txtBox.Text;
NavigationService.Navigate(new Uri(uri, UriKind.Relative));
}
i dont want to pass a text in the url, i need to pass an object instead of that like below , and any way to do this ?
Person p = new person();
uri+=p
In the first page do the following:
PhoneApplicationService.Current.State["param"] = p;
NavigationService.Navigate(new Uri("/PhonePageOne.xaml", UriKind.Relative));
And in the second retrieve the parameter:
Person p = PhoneApplicationService.Current.State["param"] as Person;
The PhoneApplicationService.State
dictionary is a temporary storage location which persists until your app is deactivated.
Other option could be to declare a static member in, for example, App.xaml.cs
and use it to save the object from one page and to retrieve from the second one.
You can use Messenger --> MVVM Light
it's an advanced use for MVVM.
Declare a messenger / Register messenger in your view model / Send what you want :)
http://mvvmlight.codeplex.com/
While the Phone application state method may work, it throws exception when you come back from dormancy. Its not designed to store large objects. A better way to do it would be by overriding the navigation function of navigationservice class. Here is a link to help you guide through it:-
http://www.kunal-chowdhury.com/2013/10/passing-object-to-wp-navigation-service.html