Hey Guys
I'm using TabbedPage having two child inside e.g. A and B (XAML)
Now when I'm navigating to TabbedPage so, A page OnAppearing invoking two time which my default page in tab. is this the default behavior in tab or I'm doing something wrong ?
Thanks
Answers
Has there been any movement on this? I'm experiencing the same issue. I have a TabbedPage with three child pages. At startup, OnAppearing for the first page is called twice. If I then tab to the third, then the second page, the OnAppearing for the first page is called again! The first page has a trivial amount of code in it, and the second and third page have none, so I'm sure this isn't related to my specific pages.
As a work-around, I used the CurrentPageChanged event and a custom interface named IActivatePage on every tabbed page. It has a single method, Activate(bool), that is invoked from the TabbedPage:
Turns out I like this solution better anyway.
Thanks @Dan . I will try this
Found the problem. In Android folder ->MainActivity if you change FormsAppCompatActivity to FormsApplicationActivity, then it works how it should work.
Maybe that is bug under FormsAppCompatActivity, the first child page onAppearing method gets invoked twice and other child pages onAppearing method gets invoked even if you don't switch to that tab.
Same issue @JamesMontemagno is there any solution.... i have the list view in tabbed page and i have to use appcompatactivity bcoz of custom rendering of tabbar
I have the same issue and I need to use appcompatactivity as well.
I just stumbled over this too :-(
think this bug has been fixed in the latest release.
Andrew, do you call the latest release a pre release? If not then the bug is not fixed.
Got the same bug
For info, best not to use OnAppearing because two instances of the page seem to be created or perhaps the first instance is disposed of, can someone report it on bugzilla please.
I'm having the same issue XF usgin 2.3.3.180
I still have the same bug with 2.3.3.193, When a tab is swiped the tab N-1 OnAppearing is also executed
Ok as another work around (not sure how efficient though but it works for me)
I use a static boolean in my first tab and I initialize it as true in my constructor
On my OnAppearing method I check if my bool is true (this means it is the first time I enter the OnAppearing method)
If my flag is true do nothing just make the flag false
Then the second time I re-enter the OnAppearing my flag will be false and I will excecute any code I want.
Hello, I have the same issue, my post: https://forums.xamarin.com/discussion/101000/possible-bug-tabbed-page
some solution? I'am using xamarin forms 2.3.4.247
Same here.
It's crazy that still with the new version 2.5 we have the same bug and no one fixed it.
This is very annoying as OnAppearing can be very important for many of us.
i have the same problem
y, pretty annoying bug :-(
On the main TabbedPage, after you've added child pages, setting the CurrentPage property to null should fix the problem.
Yes, it fixes the problem, thanks @chaosifier.
Fixed, indeed. But another problem appeared: ToolbarItems of the first page are not rendered on the Toolbar
Yes, same problem here. Why can't we have nice things?
Edit: Found a GitHub issue for this bug : https://github.com/xamarin/Xamarin.Forms/issues/1438
It appears that the issue will be fixed in 3.0.
Thank you @chaosifier, fixed my problem.
@chaosifier Setting the CurrentPage to null after every addition? How does the it get fixed to the correct? I just get a NullPointerException