0

我对 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 上的作品。

4

1 回答 1

1

Shell BackButtonBehavior 命令绑定在 UWP 中不起作用

派生自 Xamarin Form 源代码。BackButtonBehavior尚未针对 UWP 平台实现,我们可以在此处此处找到 Android 和 IOS 实现。但是对于 uwp 没有这样的跟踪器,并且在 UWP 中没有这样的价值ShellRenderer对于这种情况,我们建议您在Xamarin Forms github中发布新功能请求。

于 2020-11-25T08:48:37.043 回答