I wish I answered the vjsrinath answer above; this is IMO the best way to do this. Thank you very much!
Most likely, this is the closest thing that I saw how the iOS model works, where from the first page you called performSegue (== NavigateTo). Then you get a callback called prepareForSegue, which allows you to set variables on the landing page, set a delegate (usually for yourself), something like this.
To transfer a complex object, it removes the missing transfer parameters in the URL.
As an obvious example, let's say I want to pass the version string of my application into the "About" field, which is in a separate project:
In the calling class:
private void About_Click(object sender, EventArgs e) { NavigationService.Navigate(new Uri("/Library;component/Pages/About.xaml", UriKind.Relative)); } protected override void OnNavigatedFrom(NavigationEventArgs e) { if (e.Content is About) { About page = e.Content as About; if (page != null) { page.VersionString = App.VersionText; } } base.OnNavigatedFrom(e); }
In the About class:
public partial class About : PhoneApplicationPage { public string VersionString { get; set; } protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); versionTextBlock.Text = VersionString; } }
This is a very simple example, but the property you are passing through can be any object, which makes it very powerful. Of course, it can include callbacks, such as "saveButtonPressed", etc., Therefore, the save processing can be performed in the calling class and not in the presented view, which is pretty red for the convenience of the code. eg.
page.OnSaveButtonPressed = this.SaveButtonPressedHandler; // Pass object to save as parameter
radsdau Mar 20 '13 at 22:36 2013-03-20 22:36
source share