[Desktop] ItemsWrapGrid does not work in ListView.ItemsPanel when used as ItemsPanelTemplate
Author: kucintCreated Dec 11, 2024Updated Sep 28, 2026
Current behavior
define user control with following content:
<UserControl.Resources>
<CollectionViewSource x:Name="CategoryCollectionViewSource" IsSourceGrouped="True" />
</UserControl.Resources>
<ListView ItemsSource="{x:Bind CategoryCollectionViewSource.View, Mode=OneWay}"
SelectionMode="Single"
ShowsScrollingPlaceholders="True"
BorderThickness="{ThemeResource ListBoxBorderThemeThickness}"
BorderBrush="{ThemeResource ListBoxBorderThemeBrush}"
SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<!--If the following line (<ItemsWrapGrid/>) will be commented out
and the PRJ will be launched in net9.0-desktop mode,
5 Items (A, B, C, D, E), will be displayed in a ListView.
However, if the following line is active, nothing will be displayed.
Note: In net9.0-windows it works as expected with and without that line.
Our fazit: ItemsWrapGrid is not compatible with net9.0-desktop.-->
<ItemsWrapGrid/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem" BasedOn="{StaticResource DefaultListViewItemStyle}">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="Margin" Value="0,0"/>
<Setter Property="Padding" Value="15,0,15,0"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:Item">
<TextBlock Text="{x:Bind Label}" HorizontalAlignment="Center"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>and use it in a Page:
<Grid>
<acc:AccordionCtrl x:Name="AccordionCtrl"
Grid.Column="0" Grid.Row="0"
Margin="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
</Grid>
Expected behavior
this works correctly on WindowsAppSdk:
but fails on Desktop:
Apparently ItemsWrapGrid fails to display its content when used as a template in ListView.ItemsPanel
How to reproduce it (as minimally and precisely as possible)
MINIMAL REPRO PROJECT: MWEApp.zip
Workaround
none
Works on UWP/WinUI
Yes
Environment
No response
NuGet package version(s)
No response
Affected platforms
Skia (WPF)
IDE
Visual Studio 2022
IDE version
No response
Relevant plugins
"Uno.Sdk": "5.5.54"
Anything else we need to know?
No response
Source: unoplatform/uno