I'm making app in Xamarin with MVVMCross. This is my code:
Android View (iOS is almost the same):
var button = (Button)FindViewById(Resource.Id.button3);
var set = this.CreateBindingSet<MenuView, MenuViewModel>();
set.Bind(button).To(vm => vm.CommandNavigateToSecondPage);
set.Apply();
Core ViewModel:
public ICommand CommandNavigateToSecondPage
{
get
{
return new MvxCommand((() =>
{
ShowViewModel<SecondPageViewModel>();
}));
}
}
I want to have a default back button that will navigate me to previous page. I made same navigation with simple function in core and there was back button. Like this:
public void Navigate()
{
ShowViewModel<SecondPageViewModel>();
}
MVVM is all about binding this is why I want to make it in this way.
Close(this);- Fahadsk