NavigationHelper.FindFrame issue?

May 30, 2013 at 6: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.

Why?
Where I wrong?

Thanks in advance.
Coordinator
Jun 3, 2013 at 10: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 8:55 AM
Thanks.