Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 446

Answer by Liyun Zhang - MSFT for With .NET Maui, what am I missing in this simple command-navigation scenario?

$
0
0

You used MainPage = new NavigationPage(new MainPlayerPage()); in the App.cs, so you didn't use the AppShell and can't use Shell.Current.GoToAsync(pageName) to navigate in the NavigationPage.

You can set the MainPage as AppShell( MainPage = new AppShell();) in the App.cs and then please use the RelayCommand attribute instead of the IAsyncRelayCommand. Such as:

namespace MySolution.Client.Core.ViewModels{    public partial class MainPlayerViewModel : ObservableObject    {        [ObservableProperty]        private String _identifier = "Just to make sure the BindingContext is set properly...";        private readonly INavigationService navigationService;        public MainPlayerViewModel(INavigationService navigationService)        {            this.navigationService = navigationService;              }        [RelayCommand]        private Task NavigateToEditPage()            => navigationService.GoToEdit();        [RelayCommand]        private Task ChangeSecondLabelText()        {            Identifier = "And now we change the text of the second label...";            return Task.CompletedTask;        }    }}

Viewing all articles
Browse latest Browse all 446

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>