Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

OnCurrentPageChanged TabbedPage, infinite loop

$
0
0

Hello,
I have the same problem : https://stackoverflow.com/questions/54657758/how-to-set-the-currentpage-property-of-a-tabbedpage-in-the-oncurrentpagechanged

If I change the CurrentPage in OnCurrentPageChanged, I have an infinite loop. My client want a previous and next tab button...
They button change MVVM selected Item and I want to go back in the Children[1] (<- the loop)

    protected override void OnCurrentPageChanged()
    {
        base.OnCurrentPageChanged();
        if((this.CurrentPage == this.Children.First() || this.CurrentPage == this.Children.Last()) && !init_page)
        {
            this.view_model.CurrentItem = this.CurrentPage == this.Children.First() ? this.view_model.PreviousItem : this.view_model.NextItem;
            this.SelectedItem = this.Children[1]; // Boucle infinie
        }
    }
  1. Last Tab call OnCurrentPageChanged
  2. this.Children[1] call OnCurrentPageChanged
  3. Last Tab call OnCurrentPageChanged
  4. this.Children[1] call OnCurrentPageChanged
  5. ...

Thanks


Viewing all articles
Browse latest Browse all 89864

Trending Articles