title: Pass value from another page to MainPage.xaml in Silverlight when using Navigation?
body: <p>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:</p>
  
  <pre><code>NavigationService.Navigate(new Uri("/OpenPage.xaml", UriKind.Relative));
  </code></pre>
  
  <p>From the mainpage - this is not a child of the MainPage as the RootVisual is replaced - I can call this:</p>
  
  <pre><code>NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>        MainPage m = (MainPage)Application.Current.RootVisual;
          m.Document = "Hello World";
  </code></pre>
  
  <p>Or this:</p>
  
  <pre><code>((MainPage)root).Document = "Hello World";
  </code></pre>
  
  <p>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.<br>
  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?</p>