I have a Page in Silverlight which is Navigated from the MainPage.xaml, called OpenPage.xaml, I then want to pass a value back to the MainPage.xaml - this OpenPage.xaml is called using this:
NavigationService.Navigate(new Uri("/OpenPage.xaml", UriKind.Relative));
From the mainpage - this is not a child of the MainPage as the RootVisual is replaced - I can call this:
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
To return to the MainPage - however I need to pass a value from OpenPage.xaml to the MainPage.xaml - how to I access the MainPage instance - I have a Property called Document however when I do this:
MainPage m = (MainPage)Application.Current.RootVisual;
m.Document = "Hello World";
Or this:
((MainPage)root).Document = "Hello World";
I get an invalid cast exception because I think it is trying to cast the OpenPage.xaml to MainPage.xaml - how to I get the NavigatedTo Page, I want to set the property on MainPage.xaml from OpenPage.xaml.
I also want to pass values from the MainPage.xaml to another page SavePage.xaml - but this has the same issue - how do I resolve this?