AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.11k stars 2.26k forks source link

Add SpacingProperty to VirtualizingStackPanel #17356

Open Neakita opened 1 month ago

Neakita commented 1 month ago

What does the pull request do?

This PR adds SpacingProperty from StackPanel to VirtualizingStackPanel and complements MeasureOverride and ArrangeOverride accordingly

What is the current behavior?

At the moment, VirtualizingStackPanel does not have SpacingProperty and instead you have to use Margin on items and negative Margin in their common container to achieve the same result.

What is the updated/expected behavior with this PR?

Port SpacingProperty from StackPanel to VirtualizingStackPanel taking virtualization into account.

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Fixed issues

Fixes #17336

avaloniaui-bot commented 1 month ago

You can test this PR using the following package version. 11.3.999-cibuild0052800-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

cla-avalonia commented 1 month ago
Neakita commented 1 month ago

@cla-avalonia agree

avaloniaui-bot commented 1 month ago

You can test this PR using the following package version. 11.3.999-cibuild0052854-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

avaloniaui-bot commented 1 month ago

You can test this PR using the following package version. 11.3.999-cibuild0052858-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

avaloniaui-bot commented 1 month ago

You can test this PR using the following package version. 11.3.999-cibuild0052868-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Neakita commented 1 month ago

Seems to be working now:

https://github.com/user-attachments/assets/7ffc0807-1d72-47cf-9d1c-6c927a7bbe98

although there are some TODO’s that require attention: https://github.com/Neakita/Avalonia/blob/fd2d0f4bb201c9e9034b5f87d6e7f47bc4a6d9bc/src/Avalonia.Controls/VirtualizingStackPanel.cs#L233 https://github.com/Neakita/Avalonia/blob/fd2d0f4bb201c9e9034b5f87d6e7f47bc4a6d9bc/src/Avalonia.Controls/VirtualizingStackPanel.cs#L719

and also the obvious lack of tests (they are only two and they do not check, actually, virtualization), about which I need some third party opinion.

avaloniaui-bot commented 1 month ago

You can test this PR using the following package version. 11.3.999-cibuild0052870-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]