I have a TabbedPage, which includes 3 pages (A,B,C). I need to detect (using some override method) when a page is active/selected from tabbed control. I tried some override methods such us OnAppearing with no result, because during debugging process I noticed OnAppearing was fired when TabbedPage was firstly initialized, so when I selected for example the second page (page B) this method was not fired. Is there any optimal way to detect switching between tabs inside child view?
Just like
ToolmakerSteve sayed, the tabbedpage has the CurrentPageChanged event, so you can override the OnCurrentPageChanged()
method of the TabbedPage. Such as:
public partial class TabbedPage1 : TabbedPage
{
public TabbedPage1()
{
InitializeComponent();
}
protected override void OnCurrentPageChanged()
{
if(CurrentPage == Children[0])//Children[0] is the page A
{
....
}else if(CurrentPage == Children[1])//Children[1] is the page B
{
.....
}
else
{
......
}
base.OnCurrentPageChanged();
}
}