lepoco / lepoco/wpfui

ListView does not scroll correctly

Open
#917 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

When using a ListView the Listview will not scroll as expected when many items are in the list, instead the whole page will scroll.

To Reproduce
  1. Create a new "Compact" WPF UI project from project templates.
  2. Change XAML of Dashboard page to:
<DockPanel>
      <TextBlock DockPanel.Dock="Top" Text="Sample Text" FontSize="20" FontWeight="Bold" FontStyle="Italic"  Margin="0, 0, 0, 15"/>
      <ListView ItemsSource="{Binding ViewModel.ListViewItems}" />
</DockPanel>
  1. Change the corresponding ViewModel to:
using System.Collections.ObjectModel;
using Bogus;

namespace ListViewTest.ViewModels.Pages;

public partial class DashboardViewModel : ObservableObject
{
    [ObservableProperty]
    private ObservableCollection<Person> _listViewItems;


    public DashboardViewModel()
    {
        var listViewItems = new Faker<Person>()
            .RuleFor(u => u.FirstName, f => f.Name.FirstName())
            .RuleFor(u => u.LastName, f => f.Name.LastName())
            .Generate(150);

        ListViewItems = new ObservableCollection<Person>(listViewItems);
    }
}


public record Person
{
    public string FirstName { get; init; }
    public string LastName { get; init; }

    public override string ToString()
    {
        return $"{FirstName} {LastName}";
    }
}
Expected behavior

Only the content part of the ListView should scroll.

Screenshots

No response

OS version

Windows 10 & 11

.NET version

.NET 8

WPF-UI NuGet version

Latest from Main

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in a new Compact WPF UI project using the Dashboard page XAML and DashboardViewModel setup described in the report, with 150 items. Start by examining the ListView layout and its containing DockPanel, then verify that only the ListView content scrolls while the page remains fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.