royalBlue
royalBlue

Reputation: 95

Windows Phone 7 "back button" how to detect?

I am trying to detect back button for windows phone 7 so far I have been using BackKeyPress() event, but it did not work? Instead of changing the page (when clicking back button on phone), it goes straight to menu! Why is that?



Code:

//BackKeyPress event handler
private void LeaveWindow(object sender, System.ComponentModel.CancelEventArgs e)
{
     this.Content = new MainPage();
}

Upvotes: 0

Views: 53

Answers (1)

nguyentt
nguyentt

Reputation: 669

Did you try:

protected override void OnBackKeyPress(CancelEventArgs e)
{
    e.Cancel = true;
}

Upvotes: 1

Related Questions