0

我不知道后窗的名称。

我不知道我怎么能做到这一点。

目前,我的代码是:

if (this.NavigationService.CanGoBack)
{
    this.NavigationService.GoBack();
}
4

1 回答 1

0

它是我的示例 - > 场景 - 它是我在主页中的框架,您可以将场景重写为此

public MainPage()
{
    InitializeComponent();
    EventRegistration();
}

private void EventRegistration()
{
    SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
    Scenes.Navigated += OnNavigated;
    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
        Scenes.CanGoBack ?
        AppViewBackButtonVisibility.Visible :
        AppViewBackButtonVisibility.Collapsed;
}

private void OnNavigated(object sender, NavigationEventArgs e)
{
    if (sender is Frame)
    {
        var sc = sender as Frame;
        SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
        sc.CanGoBack ?
        AppViewBackButtonVisibility.Visible :
        AppViewBackButtonVisibility.Collapsed;
    }
}

private void OnBackRequested(object sender, BackRequestedEventArgs e)
{
    if (Scenes.CanGoBack)
    {
        e.Handled = true;
        Scenes.GoBack();
    }
}
于 2016-02-05T10:50:05.233 回答