I have a ContentView that I use as shared code on my pages. It contains navigation links etc. In the ContentView, I am trying to access a method in my App class that has the following signature:
public void ClearNavigationAndGoToPage(Page pobj_Page)
{
MainPage = new NavigationPage(pobj_Page);
}
However, when I use the following line of code in a ContentView
App.ClearNavigationAndGoToPage(new nearbyplaces());
I get the following error message:
An object reference is required for the non-static field, method, or property 'App.ClearNavigationAndGoToPage(Page)'
I can access the method from ContentPages just not ContentViews. Any suggestions?
use App.Current to access the instance of your app class. You will need to cast it to the appropriate class before calling the custom method
((CustomType)App.Current).ClearNavigationAndGoToPage(new nearbyplaces());
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