I tried to intercept the back navigation button by subscribing to the Navigating event in the WPF project of a Xamarin Forms solution:
System.Windows.Application.Current.Navigating += new NavigatingCancelEventHandler(OnNavigating);
But OnNavigating is never called.
Is this the correct way to do it or is there a better one?
答案 0 :(得分:0)
我的经验是在iOS / Android上使用Xamarin.Forms,但是这里有:
ContentPage具有OnBackButtonPressed()事件。这是我们的用法:
protected override bool OnBackButtonPressed()
{
if (GrdDisplayName.IsVisible) //If grid is visible then hide it but don't exit
{
GrdDisplayName.IsVisible = false;
return true;
}
return base.OnBackButtonPressed(); //Allow exit
}