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

Nested ItemsRepeater in a ScrollViewer behaves weird #3

Open
balthild opened this issue Jan 9, 2021 · 2 comments
Open

Nested ItemsRepeater in a ScrollViewer behaves weird #3

balthild opened this issue Jan 9, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@balthild
Copy link

balthild commented Jan 9, 2021

Describe the bug

See the screen recording.

ItemsControl does not have such issue.

To Reproduce

https://github.com/balthild/avalonia-itemsrepeater-issue

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:itemsrepeaterissue.ViewModels;assembly=itemsrepeaterissue"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="itemsrepeaterissue.Views.MainWindow"
        Icon="/Assets/avalonia-logo.ico"
        Title="itemsrepeaterissue">

    <Design.DataContext>
        <vm:MainWindowViewModel />
    </Design.DataContext>

    <ScrollViewer HorizontalScrollBarVisibility="Disabled">
        <ItemsRepeater Items="{Binding ItemGroups}" Margin="24">
            <ItemsRepeater.Layout>
                <StackLayout Spacing="24" />
            </ItemsRepeater.Layout>

            <ItemsRepeater.ItemTemplate>
                <DataTemplate>
                    <StackPanel Spacing="8">
                        <StackPanel Name="GroupTitle" Orientation="Horizontal">
                            <TextBlock Text="{Binding Title}" FontSize="24" />
                        </StackPanel>

                        <ItemsRepeater Items="{Binding Items}">
                            <ItemsRepeater.Layout>
                                <UniformGridLayout MaximumRowsOrColumns="2"
                                                   MinColumnSpacing="12"
                                                   MinRowSpacing="12"
                                                   ItemsStretch="Fill" />
                            </ItemsRepeater.Layout>

                            <ItemsRepeater.ItemTemplate>
                                <DataTemplate>
                                    <Border Padding="12" Background="#EEEEEE">
                                        <StackPanel Spacing="6">
                                            <TextBlock Text="Item name:" />
                                            <TextBlock Text="{Binding}" />
                                        </StackPanel>
                                    </Border>
                                </DataTemplate>
                            </ItemsRepeater.ItemTemplate>
                        </ItemsRepeater>
                    </StackPanel>
                </DataTemplate>
            </ItemsRepeater.ItemTemplate>
        </ItemsRepeater>
    </ScrollViewer>

</Window>
using System.Collections.Generic;
using System.Linq;

namespace itemsrepeaterissue.ViewModels {
    public class MainWindowViewModel : ViewModelBase {
        public class ItemGroup {
            public string Title { get; }
            public IEnumerable<string> Items { get; }

            public ItemGroup(string title, IEnumerable<string> items) {
                Title = title;
                Items = items;
            }
        }

        public IEnumerable<ItemGroup> ItemGroups =>
            new[] { 20, 20, 5, 2, 2, 2 }.Select(n => {
                return new ItemGroup(
                    $"Group with {n} items",
                    Enumerable.Range(0, n).Select(i => $"Item {i}")
                );
            });
    }
}

Desktop (please complete the following information):

  • OS: Windows 10 (20H2, 19042.685)
  • Version 0.10.0-rc1
@grokys
Copy link
Member

grokys commented Jan 9, 2021

Could this be microsoft/microsoft-ui-xaml#3393 ?

Edit: actually looks like it's not as I don't think I see scrolling up in the recording.

@balthild
Copy link
Author

balthild commented Jan 9, 2021

Probably not. microsoft/microsoft-ui-xaml#1887 says it's specifically when using MaximumRowsOrColumns. But in the example program, after I removed the MaximumRowsOrColumns property on UniformGridLayout, the issue is still there.

In the recording, I'm not scrolling up the mouse wheel, but the ScrollViewer automatically scrolls to some positions above when it's nearly reaching the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants