0
votes

In my WP8 App, I am navigating from one screen to another based on some events. Say, after initiating the event(http call which would take me to a new screen, after successful response), I click on back key, the previous screen is shown to me, but since the earlier event was already fired, after the event completion a new screen is shown.

So, How should I handle this back key press.

I have tried searching it on net as well, but did not get much help. [Edit :] I want to stop my async calls on the current screen when its back key is pressed, I did some searching and found that using Cancellationtoken is one such approach. But, I would want to know how exactly to use it if I am using HttpWebRequest request, response classes

1
can you explain in more details with some example steps?Maulik Shah

1 Answers

0
votes

Since you did not mention what is the expected behavior, I would assume that what you want is that in some condition you expect that back key press won't lead you to the previous page. If so, you should override the BackKeyPress method in the page where back key is pressed.

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
    if (someCondition) {
        e.Cancel = true;
    }
    base.OnBackKeyPress(e);
}

Please let me know if it is what you expected.