CollectionView
throws NRE
when ItemTemplate
uses a ViewCell
as parent #24379
Closed
Description
Description
If using a ViewCell
in the DataTemplate
, the application throws an exception (NRE).
<CollectionView
ItemsSource="{Binding Events}"
SelectionMode="None"
>
<CollectionView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label
LineBreakMode="WordWrap"
Style="{StaticResource SubHeadline}"
Text="{Binding .}"
FontAttributes="Bold"
VerticalTextAlignment="Center"
/>
</ViewCell>
</DataTemplate>
</CollectionView.ItemTemplate>
<CollectionView.EmptyView>
<Label
Text="No items..."
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
/>
</CollectionView.EmptyView>
</CollectionView>
Steps to Reproduce
- Fork the repro
- Run it on windows (not tested any other platforms)
- See that an exception is thrown
- Replace
ViewCell
with aGrid
and see that it is working afterwards
Link to public reproduction project repository
https://github.com/AndreasReitberger/MauiCollectionViewBug
Version with bug
8.0.80 SR8
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
Replace the ViewCell
with a Grid
or something similar.
Relevant log output
No response