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?
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With