Pass value from another page to MainPage.xaml in Silverlight when using navigation?

I have a page in Silverlight that is navigating from MainPage.xaml called OpenPage.xaml. Then I want to pass the value back to MainPage.xaml - this OpenPage.xaml is called using this:

NavigationService.Navigate(new Uri("/OpenPage.xaml", UriKind.Relative));

From the main page - this is not the MainPage child, as RootVisual is replaced - I can call it:

NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));

To return to MainPage - however, I need to pass the value from OpenPage.xaml to MainPage.xaml - how do I access the MainPage instance - I have a property called Document, but when I do this:

        MainPage m = (MainPage)Application.Current.RootVisual;
        m.Document = "Hello World";

Or that:

((MainPage)root).Document = "Hello World";

, , OpenPage.xaml MainPage.xaml - NavigatedTo, MainPage.xaml OpenPage.xaml. < > MainPage.xaml SavePage.xaml - - ?

+5
2

: -

NavigationService.Navigate(new Uri("/MainPage.xaml?value=Hello%20World", UriKind.Relative);

MainPage , : -

string value =  this.NavigationContext.QueryString["value"];

Edit

.

, , . , MessageService, : -

interface IMessageService
{
    Guid Store(object value)
    object Retrieve(Guid key)
}

: "

public class MessageService : IMessageService
{
    public static IMessageService Default { // singleton stuff here }
}

OpenPage MessageService.Default.Store Guid .

MainPage , MessageService.Default.Retrieve, .

+6
Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()

        InitializeComponent()

        ContentFrame.Source = New Uri("/About", UriKind.Relative)

        ...............
0

All Articles