Hello,
Welcome to our Microsoft Q&A platform!
I guess the BindingContex can be the problem but i dont have a idea how i fix it
Yes, that is the point. The ItemDateplate's bindingContext is the Model class and is the lower level of the the collectionView's. To achieve the function, try to reset the BindingContext
for the item template like : ItemsSource="{Binding BindingContext.DataCollection}" BindingContext="{x:Reference collectionView}"
Please don't use the nested listVie or collectionView, which may raise the scrolling problem. To display a collection of data in the item template, try using BindableLayout
instead.
<CollectionView x:Name="collectionView" ItemsSource="{Binding DataCollection}">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Label Text="{Binding Content}"/>
...
<StackLayout BindableLayout.ItemsSource="{Binding BindingContext.DataCollection}" BindingContext="{x:Reference collectionView}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout BackgroundColor="LightBlue">
<Label Text="{Binding Content}"/>
...
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Best Regards,
Jarvan Zhang
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.