MVVM and Navigation --- full on PEBCAK?

XamtasticXamtastic Member ✭✭✭

I am trying to Navigate to another Page in a View because this control is HUGE and copy/paste is so 1997.

Running the code below I get an error:
"PushAsync is not supported globally on Windows, please use a NavigationPage."

public class MyViewModel
INavigation _navigation;

    public Command GotoCommand { get; private set; }
    async Task ExecuteGotoCommand()
        _await _navigation.PushAsync( new NavigationPage( new MyNextPage() ) );

    public MyViewModel(INavigation navigation) 
        _navigation = navigation;
        GotoCommand = new Command(async () => await ExecuteGotoCommand());

Also get error with:

  • App.Current.MainPage.Navigation
  • without "new NavigationPage"

Best Answer


  • XamtasticXamtastic Member ✭✭✭

    Gotcha! ....that makes sense. Thanks!

    I'll look around to figure out how to remove that bar at the top now haha. Thanks again!!!!

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    If it helps, there is an attached property from NavigationPage for something like SetHasNavigationBar you can set to false on your Page. I don't have the exact name in front of me, but just check the properties of the NavigationPage and you will find it.

  • XamtasticXamtastic Member ✭✭✭

    Yup, that's what I just tried and ur spot on. Thanks!!!

Sign In or Register to comment.