Hello,
Welcome to our Microsoft Q&A platform!
You can use BindableLayout.GetItemsSource()
to get the list size in Data template selector of Bindable layout,
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
StackLayout sl = container as StackLayout;
List<Person> ss= BindableLayout.GetItemsSource(sl) as List<Person>;
int countValue=ss.Count;
return ((Person)item).Age >= 20 ? ValidTemplate : InvalidTemplate;
}
Here is running screenshot.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.