In my application I am using a popup in a page. When I press on back key, I need to close the popup if it is open and stay on the page. When I pressed on the back key, the popup not closed and the page goes to previous one. To close the popup now I use the following code in the back key press event.
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if (myPopup.IsOpen)
myPopup.IsOpen = false;
else if (NavigationService.CanGoBack)
NavigationService.GoBack();
}
When using this code, the popup will close but also goes to the previous page. I need to go back only if popup is in closed state. How can I do this?
Problem Solved.
Instead of using
I used the
back key press event
of the page