NavigationHelper.FindFrame issue?

May 30, 2013 at 5:36 PM
Hello everybody.

Mostly for self-training purpose I’m playing with the method: var frame = NavigationHelper.FindFrame(null, this);
I'm invoking it from:

MainWindow constructor.
Page (user control) constructor.
Page IContent methods implementation.

But only in the method public void OnNavigatingFrom(NavigatingCancelEventArgs e) { } it return the ModernFrame object. Otherwise it returns always null.

Where I wrong?

Thanks in advance.
Jun 3, 2013 at 9:45 PM
FindFrame with name 'null' only works when the provided context (in your case 'this') is hosted in a ModernFrame. The MainWindow itself is the root of the UI and is not hosted in a ModernFrame, therefor null is returned. The page ctor is also not a valid location, because the page itself is not (yet) hosted in a ModernFrame, it is currently being created and not part of the visual tree. OnNavigatingFrom works because your content page is hosted in a ModernFrame.
Jun 4, 2013 at 7:55 AM