首页 文章

如何在创建页面时覆盖默认的BackKey按钮

提问于
浏览
0

这里是创建页面时的默认backKey按钮:

问题:

如何覆盖这个?我想在这个backKey canGoBack之前检查一下!

<Button Content="Button" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" HorizontalAlignment="Left" 
Margin="16,15,0,0" VerticalAlignment="Top" Height="55"/>


---- Update : in LayoutAwarePage.cs


protected virtual void GoBack(object sender, RoutedEventArgs e)
        {
            // Use the navigation frame to return to the previous page
            if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack();
        }

1 回答

  • 0

    UPDATE 1

    protected override void GoBack(object sender, RoutedEventArgs e)
    {
        base.GoBack(sender, e);
        //Your logic goes here
    }
    

    我认为你正在使用 LayoutAwarePage 类 . 它实现了 GoBack 事件 . 您可以编辑实施 . LayoutAwarePage.cs将在项目的公共文件夹中 .

相关问题