简体   繁体   English

如何在Windows Phone中将后退按钮应用于画布?

[英]How to apply back button to canvas in windows phone?

I am trying to do an windows application. 我试图做一个Windows应用程序。 In the below image you can see that in Page1 where a button is there. 在下图中,您可以在Page1中看到一个按钮。 When I select this button a canvas is opened. 当我选择此按钮时,将打开一个画布。 What I want to do is? 我想做的是? When this canvas is opened in the Page1(right side) itself, if I select back button of windows phone. 当我在Page1(右侧)本身中打开此画布时,如果我选择Windows Phone的后退按钮。 Then the canvas should disappear. 然后画布应该消失。 How to do this kind of task? 怎样做这种任务?

在此处输入图片说明

You can detect and cancel the navigation with the back button by overriding the OnBackKeyPress method and setting e.Cancel to true. 通过覆盖OnBackKeyPress方法并将e.Cancel设置为true,可以使用后退按钮检测和取消导航。

From there, it's just a matter of detecting whether the canvas is displayed. 从那里开始,只需检测是否显示了画布即可。

protected override void OnBackKeyPress(CancelEventArgs e)
{
    if (EHeightCanvas.Visibility == System.Windows.Visibility.Visible)
    {
        e.Cancel = true;
        EHeightCanvas.Visibility = System.Windows.Visibility.Collapsed;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM