0

I am have created a Flyout Control (extending UserControl) in order to have Header Menu navigation for a Windows 8 App using C# and XAML.

In this layout I have some buttons with Click listeners. These buttons are used for the navigation among the various pages of the app.

Thus, I would like to ask you how can I access the parent page's Frame in order to navigate to the other pages?

Thanks a lot in advance!

Dimitris Makris
  • 5,183
  • 2
  • 34
  • 54

1 Answers1

1

You can always get the frame with

var frame = Window.Current.Content as Frame;
Jeff Brand
  • 5,623
  • 1
  • 23
  • 22
  • I had tried this, but an ArgumentNullException is thrown. Addition info: Value cannot be null. This exception is thrown in the OnNavigatedFrom method of the LayoutAwarePage.cs. Any hint about this? – Dimitris Makris Sep 17 '12 at 15:33
  • I was thinking you needed to get ahold of the frame from within the user control. Why do you need to acquire the current frame from a page you are leaving? OnNavigatedFrom is invoked immediately after the Page is unloaded and is no longer the current source of a parent Frame, thus the reason you are getting a ArgumentNullException being thrown. – Jeff Brand Sep 17 '12 at 16:36
  • So, since I want to navigate to another page when I click on a button of the Flyout Control, which is the correct way to do this? – Dimitris Makris Sep 17 '12 at 16:46
  • In the button handler, acquire the frame using the code above then use frame.navigate to your new page – Jeff Brand Sep 17 '12 at 17:12