0
votes

First I call the child page(User Control) from parent page(Xaml).. then I have to redirect or loading the parent page from child page.

RootFrame.Navigate(new Uri("/Views/pages/page1.xaml", UriKind.Relative));

I used this code for navigating from User control to XAML page. But this is not applicable for user Control page. So I referred the below one that is working for the first time but second time it will not navigate to the xaml(parent) page.

var frame = App.Current.RootVisual as PhoneApplicationFrame; frame.Navigate(new Uri("/Views/pages/page1.xaml", UriKind.Relative));

http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/how-to-navigate-to-other-page-from-a-user-control-in-windows/ I tried this link also But can't get the result..

So please anyone give the solution ...

1
Did you try NavigationService.Navigate(new Uri("/Views/pages/page1.xaml", UriKind.Relative));?hmnzr
Your task is to navigate from a page to page1.xaml ?user2579857

1 Answers

0
votes

First of all, UserControls are not Pages. And please do not use them as such. UserControls are meant to be re-usable sections, that you could place in more than one Pages. That explained, you cannot (and should not) navigate from a Page to a UserControl. Its a NO NO.

The best way to communicate to the parent container (the Page, in this case) is via Events. You may raise an event when you are done with any activity in the User Control. The Page can listen to the activity and close the User Control, and do any extra stuff that it needs to do.

See an example: How do I make an Event in the Usercontrol and Have it Handeled in the Main Form?

Disclaimer: This example is a Windows Form example. You can adapt this to Windows Phone.