If you use the MVVM architecture, you can submit the navigation page after registering with Messenger. Create a model class (say NavigateToPageMessage) with a string variable (e.g. PageName). You want to pass the line from homepage.xaml to newpage.xaml and then to the Home viewmodel just send a message like this under the command you linked (e.g. HomeNavigationCommand)
private void HomeNavigationCommandHandler() { Messenger.Default.Send(new NavigateToPageMessage {PageName = "newpage"}); }
In the new Viewmodel, you need to register this messenger,
Messenger.Default.Register<NavigateToPageMessage>(this, (action) => ReceiveMessage(action)); private object ReceiveMessage(NavigateToPageMessage action) { var page = string.Format("/Views/{0}.xaml", action.PageName); NavigationService.Navigate(new System.Uri(page,System.UriKind.Relative)); return null; }
// Assuming your views are in the view folder
source share