C#导航服务goback

时间:2016-02-05 10:19:14

标签: c# navigationservice

我不知道后窗的名字。

我不知道怎么做。

目前,我的代码是:

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

1 个答案:

答案 0 :(得分: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();
    }
}