How to navigate with objects in windows phone 8?

前端 未结 3 1798
广开言路
广开言路 2021-01-07 11:52

I need to navigate from one xaml page to another with an Object not a String ..

present code is :

  private void Border_ManipulationStarted(object s         


        
相关标签:
3条回答
  • 2021-01-07 12:32

    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

    0 讨论(0)
  • 2021-01-07 12:35

    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.

    0 讨论(0)
  • 2021-01-07 12:41

    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/

    0 讨论(0)
提交回复
热议问题