I created a Service (Navigation Service, NavigationService), but when I use in my ViewModel, nothing happens when I use the "PushAsync" but when I use the "PopModalAsync" present my page I want to surf, but I want to use "PushAsync"
My INavigationService
public interface INavigationService
{
Task IrPara(Page page);
}
My NavigationService
public class NavigationService:INavigationService
{
public NavigationService()
{
}
public async System.Threading.Tasks.Task IrPara(Xamarin.Forms.Page page)
{
await Teste.App.Current.MainPage.Navigation.PushAsync(page);
}
}
My ViewModel
public class myViewModel:INotifyPropertyChanged
{
readonly INavigationService navegar;
public ICommand testCommand{ get; set;}
public ObservableCollection<GrupoModel> Grupos{ get; set; }
public myViewModel()
{
testCommand = new Command(this.ActionTeste);
navegar = DependencyService.Get<INavigationService>();
}
public void ActionTeste(){
navegar.IrPara(new NextPage());
}
}
My View