Search code examples
windows-phone-7overridingkeypress

close upon backKeyPress windows phone


I have a problem. I have an popup that i want to close if the back key is pressed, now its closing the application. This it what i have done:

    protected override void OnBackKeyPress(CancelEventArgs e)
    {
        if (dayselect.IsOpen == true)
        {
            dayselect.IsOpen = false;
            dayselectbackground.Visibility = Visibility.Collapsed;
        }

        base.OnBackKeyPress(e);
    }

Now the application is closing as normal, what have i missed.


Solution

  • As mentioned by SwiftSharp in the comments. =)

    Actually is quite simple, you are just missing e.Cancel = true