×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    13

    Question BackKey confussion

    I met some problems on my windows phone app of the BackKey.

    For example, in page1, i press a button to navigate to page2. Then i press a button in page2 to navigate to page3.

    At this moment, i press the BackKey, and the app successfully back to page2. Then press the BackKey angin, it back to page1.

    But when the OnNavigatedTo event of page1 is done, the app automatically back to page3!!!

    Why Page3 is still in the BakcStack? Can anyone tell me what happened behind?

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    568

    Re: BackKey confussion

    Are you developing for Windows Phone 8 (as opposed to 7) and using the Fast Application Switching?

    Have a quick read of this and let us know if it explains the behaviour... http://msdn.microsoft.com/library/wi...v=vs.105).aspx

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    518

    Re: BackKey confussion

    That should not be the case normally (and I haven't seen it happen so far). You could try inspecting the Back Stack in OnNavigatedTo to see what is contained. Otherwise I believe we would need to see part of the code you are using. Something in or after OnNavigatedTo obviously is triggering another navigation (you could try overriding OnNavigatedFrom in your Page 1 and check what is triggering the navigation).

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: BackKey confussion

    Maybe you have something in your OnNavigatedTo code in page1 which trigger it to navigate to page3?
    your gonna have to give us more details in order to properly help you.

  5. #5
    Registered User
    Join Date
    Sep 2013
    Posts
    13

    Re: BackKey confussion

    Thanks for all the replies.

    Here are the code behind.

    page1 - OnNavigatedTo:
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    base.OnNavigatedTo(e);
    this.PageOut.Stop();
    this.PageIn.Begin();
    }

    And it is the similar code of page2 and page3, just to begin a storyboard to work as a transition animation.

    And i also override the OnBackKeyPress to begin a storyboard(page2 and page3)

    protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
    base.OnBackKeyPress(e);
    this.PageOut.Begin();
    }

    And the Click events of buttons on page1 and page2 are like this:
    private void Button_Click(object sender, RoutedEventArgs e)
    {
    this.PageOut.Completed += PageOut_Completed;
    this.PageOut.Begin();
    }

    void PageOut_Completed(object sender, EventArgs e)
    {
    this.NavigationService.Navigate(new Uri("/Plage2.xaml", UriKind.Relative));
    }

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    518

    Re: BackKey confussion

    Perhaps it would help to alter PageOut_Completed to:

    void PageOut_Completed(object sender, EventArgs e)
    {
    this.PageOut.Completed -= PageOut_Completed;
    this.NavigationService.Navigate(new Uri("/Plage2.xaml", UriKind.Relative));
    }

    So that following the navigation another run of the storyboard does not trigger again any navigation. Also you would add the event twice when the button is pressed again so the method would then be triggered twice. I'm not sure but this to me looks like the likely cause of your issue.

  7. #7
    Registered User
    Join Date
    Sep 2013
    Posts
    13

    Re: BackKey confussion

    Thank you very much!

    I followed your suggestion and it works well.
    Quote Originally Posted by SB Dev View Post
    Perhaps it would help to alter PageOut_Completed to:

    void PageOut_Completed(object sender, EventArgs e)
    {
    this.PageOut.Completed -= PageOut_Completed;
    this.NavigationService.Navigate(new Uri("/Plage2.xaml", UriKind.Relative));
    }

    So that following the navigation another run of the storyboard does not trigger again any navigation. Also you would add the event twice when the button is pressed again so the method would then be triggered twice. I'm not sure but this to me looks like the likely cause of your issue.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    568

    Re: BackKey confussion

    Just curious, why are you trying to use your own Storyboard page transition animations? the WP Toolkit has all the standard Windows Phone transitions built in.

  9. #9
    Registered User
    Join Date
    Sep 2013
    Posts
    13

    Re: BackKey confussion

    I know WP Toolkit transition, but I want some special animations to fit my app's design.

    As an individual developer, i am not good at coding actually and i spend more time on designing the visual effect.

    Quote Originally Posted by theothernt View Post
    Just curious, why are you trying to use your own Storyboard page transition animations? the WP Toolkit has all the standard Windows Phone transitions built in.

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    568

    Re: BackKey confussion

    Ok - just checking

    If you'd like any feedback on your final app, do post again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×