selected index returns an incorrect value on the first click

I create List items of headercontent in viewmodel and binding to Items of Tabview. I handle event TabItemTapped, I using Selectedindex property but when first click item in headercontent then Selectedindex returns an incorrect value, have to come a second click Selectedindex returns an correct value. Why did that happen? thanks!


6 Replies

SP Sakthivel Palaniyappan Syncfusion Team April 28, 2020 01:53 PM UTC

Hi TruongCP,

Greetings from Syncfusion.

We  have checked the reported issue of “Selected index returns an incorrect value on the first click”, but we are not able to reproduce the issue. We have recorded video for that, please find the video from below.
 
Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Tabview198362798.zip 

Please find the sample from below.

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/RssNews.Xamarin-master-1984343277.zip

S
ince we are not aware of your exact scenario please modify the sample with reported issue and revert us. And provide video about the issue. It will help us to investigate more and provide better solution at the earliest.

Regards,
Sakthivel P. 
 
 



TR TruongCP April 29, 2020 02:34 AM UTC

I binding SelectedIndex in ViewModel and show in message and index return incorrect when first click in event TabItemTapped. Now, I solved this by using event SelectedChanged then index return correct when first click but the problem is why? I recorded video for that.


Video


SP Sakthivel Palaniyappan Syncfusion Team April 29, 2020 12:22 PM UTC

Hi TruongCP,

Thanks for the update.

We confirmed this as bug and we have logged a defect report regarding on this and it can be tracked through our feedback portal below.

Feedback link: https://www.syncfusion.com/feedback/13944

We will include this fix in our upcoming Volume 1 Sp1, 2020 release. Which will be available on mid of May 2020.

Regards,
Sakthivel P.
 



SP Sakthivel Palaniyappan Syncfusion Team May 6, 2020 02:35 AM UTC

Hi TruongCP,

We have validated the reported issue and we would like to let you know that
after triggering the TabItemTapped event, the selection has been changed and content also updated for the next tab, so when you return the SelectedIndex before the selection has been changed it returns the previous value. If you need to use TabItemTapped to get the index of the current selected item you can use the code below.

Code Snippet:

 
private void tabView_TabItemTapped(object sender, TabItemTappedEventArgs e) 
{ 
    var tabIndex = tabView.Items.IndexOf(e.TabItem); 
} 

Please let us know, if you have any other concerns.

Regards,
Sakthivel P.
 



TR TruongCP May 6, 2020 03:53 AM UTC

So, what is diffrence between SelectedChanged and TabItemTapped when should take it, if passing data contentpage I would when click tabitem of list tabitems in headercontent  which one should i choose?. Thanks


SP Sakthivel Palaniyappan Syncfusion Team May 6, 2020 01:39 PM UTC

Hi TrungoCP,

Thanks for the update.

We would like to inform that Selection changed event is triggered when swiping the content of the tab item and tap on the header.Using SelectionChanged event, we can get the selected tabitem index from selection changed event arguments.

TabItemTapped event is triggered only when tapping on the header and we can get the tabitem from its event arguments.

If you want to perform any changes when swiping the content then you can use the selection changed event.Based on your requirement you can choose event.

Regards,
Sakthivel P.
 


Loader.
Up arrow icon