Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView does not use ItemTemplateSelector when ItemsPanel is configured #10376

Open
mattiferg opened this issue Feb 20, 2025 · 0 comments
Open
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@mattiferg
Copy link

Describe the bug

When a ListView has the ItemsPanel explicitly configured then the configured ItemTemplateSelector is not honoured.
This means that we cannot add spacing, orientation etc. to a list with more than one item template.

Steps to reproduce the bug

<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,*">

    <TextBlock Grid.Row="0" Grid.Column="0" Text="Works"/>
    <Border Grid.Row="1" Grid.Column="0" Background="Yellow">
        <ListView x:Name="GoodList" ItemsSource="{x:Bind MyItems}" ItemTemplateSelector="{StaticResource MyTemplateSelector}"/>
    </Border>

    <TextBlock Grid.Row="0" Grid.Column="1" Text="Does not work"/>
    <Border Grid.Row="1" Grid.Column="1" Background="Pink">
        <ListView x:Name="BadList" ItemsSource="{x:Bind MyItems}" ItemTemplateSelector="{StaticResource MyTemplateSelector}">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>
    </Border>
</Grid>

ListView named GoodList applies the template selector. ListView named BadList does not.

Expected behavior

Both lists in the repro should look the same.

Screenshots

Image

NuGet package version

WinUI 3 - Windows App SDK 1.6.5: 1.6.250205002

Windows version

Windows 11 (24H2): Build 26100

Additional context

No response

@mattiferg mattiferg added the bug Something isn't working label Feb 20, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

1 participant