Using the OnNavigatedFrom Method
OnNavigateFrom is called when we call the NavigationService.Navigate method. It has a NavigationEventArgs object as a parameter, which returns the landing page with the Content property, with which we can access the destination page destination "DestinationPage.xaml.cs"
First, on the DestinationPage.xaml.cs landing page, declare the SomeProperty property:
public ComplexObject SomeProperty { get; set; }
Now, in "MainPage.xaml.cs", override the OnNavigatedFrom method:
protected override void OnNavigatedFrom(NavigationEventArgs e) { // NavigationEventArgs returns destination page "DestinationPage" DestinationPage dPage = e.Content as DestinationPage; if (dPage != null) { // Change property of destination page dPage.SomeProperty = new ComplexObject(); } }
Now get the value SomeProperty in "DestinationPage.xaml.cs":
private void DestinationPage_Loaded(object sender, RoutedEventArgs e) {
Luxspes Oct 29 2018-12-12T00: 00Z
source share