Xamarin Forms Tabbed Page Load Data when tab is Select

There is an override method in TabbedPage named “OnCurrentPageChanged” that call on tab change. We can use x:Name attribute to access the element of xaml in code behind.

In Xaml, Apply x:Name attribute value.

<local:HomePage x:Name="Home">
<local:ExplorePage x:Name="Explore"> //use same for others pages

Override below method in code behind.

protected override void OnCurrentPageChanged()
            if(CurrentPage is HomePage)
                Debug.WriteLine("Home Page");
                var viewModel = Home.BindingContext as HomeViewModel;
            }else if(CurrentPage is ExplorePage)
                Debug.WriteLine("Explore Page");
                var viewModel = Explore.BindingContext as ExploreViewModel;
            // Same for other pages

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top