DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Another Way of Passing Values Between Windows Phone 7 Pages

Another Way of Passing Values Between Windows Phone 7 Pages

Jevgeni Tšaikin user avatar by
Jevgeni Tšaikin
·
Mar. 10, 12 · Mobile Zone · Interview
Like (0)
Save
Tweet
5.02K Views

Join the DZone community and get the full member experience.

Join For Free

Another appropriate way for passing data from one page to another during the navigation is in setting up destination page properties (or variables) within OnNavigatedFrom method of source page.

passing data or parameters from one page to another using onnavigatedfrom method and destination page instance by eugenedotnet


OnNavigatedFrom method is called just before a page is no longer the active page in a frame. For example this method is called if you invoke NavigationService.Navigate method from a source page. Due to the fact that OnNavigatedFrom method accepts NavigationEventArgs as input parameter you have access to the destination page stored in Content property.

Sample

I have created two pages: Page1.xaml and Page2.xaml. Inside Page2 I have added a string property named Parameter. Inside Page1 (codebehind) I have overridden method OnNavigatedFrom for setting up Page2′s Parameter property.

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
    Page2 page2Instance = e.Content as Page2;
    if (page2Instance != null)
    {
        page2Instance.Parameter = "value";
    }
}


Advantages

Probably one of advantages is that you don’t have to store values in static context, but simply pass them from one page to another. That approach is great for a wizard when you have several pages in a row and you need to store only the final result after wizard is completed.

Disadvantages

This approach cannot be applied to applications that can lose sensitive information during the suspend mode (Tombstoning), because when system restores your application from suspend mode there is no way to call OnNavigatedFrom method to set destination page properties.

Windows Phone

Published at DZone with permission of Jevgeni Tšaikin. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Artificial Intelligence (AI) And Its Assistance in Medical Diagnosis
  • What Developers Need to Know About Table Partition Pruning
  • Legacy Modernization and Hybrid Cloud with Kafka in Healthcare
  • How Low Code Demands More Creativity From Developers

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo