Dynamic content on Selected Item

hello, I would like to create a tabview that loads inside a label with the title of the selected TabItem
I can do it with the TabItemTappedEventArgs but it only works if the item on the top menu is selected.
I would also like to do it when swiping, looking for I also found the SelectionChangedEventArgs event from this event it is not possible to send any Content for the selected item.
All this however I would like to do it using only c # and no xaml

1 Reply 1 reply marked as answer

JK Jeya Kasipandi Syncfusion Team June 14, 2021 12:31 PM UTC

 Hi Salvatore Lorello,

Greetings from Syncfusion.

We have validated your query and we suggest you use SelectionChanged or SelectionChanging event to achieve your requirement while swiping. You can load the content of tab item by using the index returned by the Selection Changing or Selection Changed event arguments. We have created sample based on this and please find the sample from below link

Sample link: https://www.syncfusion.com/downloads/support/forum/166313/ze/TabviewSample652185305

In this sample, we have loaded content based on the selected item index in selection changing event as like below code snippet
 
 
private void tabView_SelectionChanging(object sender, Syncfusion.XForms.TabView.SelectionChangingEventArgs e)
{
if (e.Index == 0)
{
Grid callsGrid = new Grid { BackgroundColor = Color.Yellow };
tabView.Items[e.Index].Content = callsGrid;
}
else if (e.Index == 1)
{
Grid favoritesGrid = new Grid { BackgroundColor = Color.Green };
tabView.Items[e.Index].Content = favoritesGrid;
}
else if (e.Index == 2)
{
Grid contactsGrid = new Grid { BackgroundColor = Color.Blue };
tabView.Items[e.Index].Content = contactsGrid;
}
}
 
Please check with the above and let us know if you have any concern.

Regards,
Jeya K

 


Marked as answer
Loader.
Up arrow icon