在我的应用程序中的某些情况下,我必须取消返回导航。我正在使用代码:
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
if (e.NavigationMode == NavigationMode.Back)
{
if (WaitPanelGrid.Visibility == System.Windows.Visibility.Visible)
{
e.Cancel = true;
}
}
base.OnNavigatingFrom(e);
}
一切都很好,除了一件事:在这个页面我有过渡:
<toolkit:TransitionService.NavigationInTransition>
<toolkit:NavigationInTransition>
<toolkit:NavigationInTransition.Backward>
<toolkit:TurnstileTransition Mode="BackwardIn" />
</toolkit:NavigationInTransition.Backward>
<toolkit:NavigationInTransition.Forward>
<toolkit:TurnstileTransition Mode="ForwardIn" />
</toolkit:NavigationInTransition.Forward>
</toolkit:NavigationInTransition>
</toolkit:TransitionService.NavigationInTransition>
<toolkit:TransitionService.NavigationOutTransition>
<toolkit:NavigationOutTransition>
<toolkit:NavigationOutTransition.Backward>
<toolkit:TurnstileTransition Mode="BackwardOut" />
</toolkit:NavigationOutTransition.Backward>
<toolkit:NavigationOutTransition.Forward>
<toolkit:TurnstileTransition Mode="ForwardOut" />
</toolkit:NavigationOutTransition.Forward>
</toolkit:NavigationOutTransition>
</toolkit:TransitionService.NavigationOutTransition>
并在 OnNavigatingFrom 中调用 Cancel 停止应用程序从导航返回,但转换仍在工作,所以最后我只有黑屏,因为页面没有改变,但它被动画并移动到屏幕后面的某个地方。
我的问题是:如何取消导航和转换?