Is there any way of getting main page object from any of its child controls? As a possible solution I see here bubbling through parents and stopping as soon as a parent is of PhoneApplicationPage type. It is fine for me, but what if I need to do that from other pages? I.e. How to get main page of an application from everywhere within the application?
+2
A:
In your App.xaml, there is a public property called RootFrame it is of type PhoneApplicationFrame class. It is the container for PhoneApplicationPages as discussed in this article.
You can always get to the RootFrame since it's at application scope. So, for example ...
var frame = Application.Current.RootVisual as PhoneApplicationFrame;
var startPage = frame.Content as PhoneApplicationPage;
The page that your app starts on is in WMAppManifest.xml
...
<Tasks>
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
</Tasks>
JP Alioto
2010-10-17 04:53:54
Thanks! It works!
Bashir Magomedov
2010-10-17 10:54:36