Giter VIP home page Giter VIP logo

Comments (9)

RicoSuter avatar RicoSuter commented on May 25, 2024

It works fine for me in the current version 2.4.1-beta (latest source code)... Clone the latest source code and run the SampleUwpApp or SampleWindowsStoreApp in debug mode and check the navigation events in the Visual Studio output. Do you see the same problems?

from mytoolkit.

danielthompson avatar danielthompson commented on May 25, 2024

We upgraded to 2.4.0 and are still seeing the issue. Investigating further...

from mytoolkit.

danielthompson avatar danielthompson commented on May 25, 2024

To give some context around this - our app is structured such that we allow random access navigation to the various views. When navigating, we first check to see if the requested target page is already on the stack. if so, we pop the intermediate pages and then navigate back to the target page. if not, we navigate forward to the target.

code:

  public async void NavigateToView(IView currentView, Type newViewType, IViewContext context)
  {
     MtPageDescription pageDescription = currentView.Frame.GetNearestPageOfTypeInBackStack(newViewType);

     if (pageDescription != null)
     {
        if (currentView.Frame.CurrentPage != pageDescription)
        {
           // Remove pages from stack until reaching the desired one.
           // http://stackoverflow.com/questions/29127993/mtframe-gobacktoasync-pop-or-navigate-back-to-nth-page-without-loading-n-1-pages
           while (currentView.Frame.PreviousPage != pageDescription)
           {
              currentView.Frame.RemovePageFromStackAt(currentView.Frame.CurrentIndex - 1);
           }

           if (currentView.Frame.CanGoBack)
              // debugger stepthrough shows this is being called when nav requested from Page2 to Page1
              await currentView.Frame.GoBackAsync()
        }
     }

     await currentView.Frame.NavigateAsync(newViewType, context);
  }

from mytoolkit.

RicoSuter avatar RicoSuter commented on May 25, 2024

Looks good without testing... However, have you tried to use GoBackToAsync?

from mytoolkit.

RicoSuter avatar RicoSuter commented on May 25, 2024

FYI: In the next version there will be a method to move a given page to the top of the stack without removing pages in between...

from mytoolkit.

danielthompson avatar danielthompson commented on May 25, 2024

Interesting, we'll try GoBackToAsync() and see if we see the same behavior.

from mytoolkit.

danielthompson avatar danielthompson commented on May 25, 2024

Turns out it was a bug in our nav method. After navigating back to the target view, we were still navigating forward to the target view.

 public async void NavigateToView(IView currentView, Type newViewType, IViewContext context)
 {
    MtPageDescription pageDescription = currentView.Frame.GetNearestPageOfTypeInBackStack(newViewType);

    if (pageDescription != null)
    {
       if (currentView.Frame.CurrentPage != pageDescription)
       {
          // nav backward - correct
       }
    }
    // nav forward - there should be an else wrapping the following statement
    await currentView.Frame.NavigateAsync(newViewType, context);
 }

from mytoolkit.

RicoSuter avatar RicoSuter commented on May 25, 2024

Ok, so this issue can be closed?

from mytoolkit.

danielthompson avatar danielthompson commented on May 25, 2024

Yes sir. Thanks for your help. We did switch to GoBackToAsync() and it seems to be working as well, nice add.

from mytoolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.