Reputation: 107
I have this code
public App()
{
...
MainPage = new NavigationPage(content);
App.Navigation.PushAsync(new homePage());
}
the PushAsync does not work, it said the navigation is not defined, so can I prove to the compiler that Navigation is defined
Upvotes: 0
Views: 2429
Reputation: 5768
Also
await Application.Current.MainPage.Navigation.PushAsync(new homePage());
Upvotes: 1
Reputation: 31
I've got my App() setup like this:
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MasterDetail());
}
My MasterDetail looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="GrowersClassified.Views.Menu.MasterDetail"
xmlns:detail="clr-namespace:GrowersClassified"
xmlns:master="clr-namespace:GrowersClassified.Views.Menu"
Title="">
<MasterDetailPage.Master>
<master:MasterPage x:Name="masterpage"/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<detail:Index/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
I think your problem might be using App.
Navigation.PushAsync(new homePage());
For me it gave an error whenever I tried to use that anyways.
Upvotes: 0
Reputation: 2159
Looks to me like the compiler is right. Your App
won't have a Navigation
property. What you probably need is:
MainPage.Navigation.PushAsync(new homePage());
Upvotes: 2