简体   繁体   中英

How to apply back button to canvas in windows phone?

I am trying to do an windows application. In the below image you can see that in Page1 where a button is there. 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. 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.

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;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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