我对 Xamarin 开发有点陌生。我尝试使用绑定命令更改后退按钮的行为,但这似乎不起作用。这是视图的代码:
<Shell.BackButtonBehavior>
<BackButtonBehavior Command="{Binding GoBack}"/>
</Shell.BackButtonBehavior>
这是视图模型的代码:
public CreatePasswordVM()
{
_goBack = new Command(GoBackButton);
}
private ICommand _goBack;
public ICommand GoBack
{
get { return _goBack; }
}
public async void GoBackButton()
{
await Shell.Current.GoToAsync("../..");
}
当我按下后退按钮时,“GoBackButton”方法没有调用。我想提一下在 Android 上的作品。