SelectionChanged is not fired when the control is visible the first time. How can I capture the initial selected tabItem in code when it is visible initially?

I would like to load data from sever to display when a tabItem is visible. I can do this whenever the selected tabItem is changed by subscribing to SelectionChanged event. The problem is that SelectionChanged is not fired when the tabView becomes visible the first time. So the SfTabView is displayed with no data initially. How can I plug in the code to load data the first time SfTabView is visible? 

3 Replies 1 reply marked as answer

SS Suganya Sethuraman Syncfusion Team June 16, 2021 02:09 PM UTC

Hi SeanLi,

Greetings from Syncfusion.

We have analyzed your query and we can achieve your requirement by using SelectionChanging event of SfTabView, please refer below link for more details about SelectionChanging event.

https://help.syncfusion.com/xamarin/tabbed-view/selection-changing

Please let us know if you have any other queries.

Regards,
Suganya Sethuraman.
 



SE SeanLi June 17, 2021 12:08 AM UTC

My problem is that when a SfTabView is displayed the first time, its first tab (tab with index 0) is shown (the selected tab is changed from NULL to 0), there is no SelectionChanged event.  So I cannot rely on the SelectionChanged event in this case. 

But I have found a solution without using SelectionChanged.


JK Jeya Kasipandi Syncfusion Team June 17, 2021 09:52 AM UTC

Hi SeanLi,

Thanks for the update.

We would like to inform that currently, we don't have selected tab set to null. So, the selected index in sftabview is initially zero. So, the selection changed event will not get fired. This is default behavior in sftabview.

Please let us know, if you have any concern.

Regards,
Jeya K

Marked as answer
Loader.
Up arrow icon