0

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 ...

jeyrus
  • 1
  • 4

1 Answers1

0

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.

Community
  • 1
  • 1
Rajeev Nair
  • 759
  • 8
  • 20
  • thanks for your reply .. But NavigationService does not accept in User control. My requirement is that i need to move from my user control to my parent page with loading(parent page should reload - means have to call OnNavigatedTo method in parent page). Any other solution there .. – jeyrus Apr 02 '14 at 05:30
  • i used the User Control as Popup. So in that popup, i clicked the Submit button after that popup will close and reload the page. can you give the link for hmnzr .. – jeyrus Apr 02 '14 at 05:32