wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

ListView does not scroll correctly

Open afluegge opened this issue 2 years ago • 2 comments

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

afluegge avatar Jan 19 '24 10:01 afluegge

Hello @afluegge,

To disable whole page scrolling, you need to add the following line to the opening tag of the page (see screenshot below): ScrollViewer.CanContentScroll="False"

By default, the content of the whole page is scrollable.

image

Let me know if that doesn't work.

frostybee avatar Jan 24 '24 00:01 frostybee

I dunno, I just feel like all Pages should just be unscrollable (don't add a ScrollView in the Control hierarchy). This way the UI is smoother and the user can still add a ScrollViewer / StackView (or their equivalent visualizing version) if needed.

Palatis avatar Feb 09 '24 19:02 Palatis