microsoft-ui-xaml: ItemsRepeater throws AccessViolationException when DataTemplate is empty

Describe the bug I got AccessViolationException when return new DataTemplate() from DataTemplateSelector. ListView and GridView deals well with it by just rendering nothing, but ItemsRepeater throws Exception.

Steps to reproduce the bug this code

<muxc:ItemsRepeater ItemsSource="{Binding SomeItems}">
    <muxc:ItemsRepeater.ItemTemplate>
        <DataTemplate/>
    </muxc:ItemsRepeater.ItemTemplate>
</muxc:ItemsRepeater>

throws AccessViolationException.

Expected behavior Do not throw Exception, just don’t render this item.

Additional context My guess is that AccessViolation appears here as selectedTemplate.LoadContent() returns null.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments

Is there a valid scenario with DataTemplateSelector ? What if one of the templates is empty and the other is not ? Should the empty template just insert items that take up no space ? If we do that then, we could end up de-virtualizing the entire list trying to fill the viewport. I would like to understand the scenario with DataTemplateSelector and the expected behavior in different cases. Yes, opening a separate bug to discuss that would be best. I merged these changes in since the two fixes are independent. Thanks!

Hmm… Description of this bug already contains this case. I just made sample code simpler… Let’s wait for MS staff…