-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
ScrollContentPresenter only looks at the first level of content for an IScrollSnapPointsInfo #17867
Comments
I think I manage to narrow down the actual problem: It looks like the When the I believe EDIT: A temporary solution is to implement a |
Cc @emmauss |
Your issue comes from VirtualizingStackPanel. |
@emmauss thanks a lot for taking the time to look into that. I first came to the same conclusion regarding the I closed it recently but I'd be more than happy to reopen it. if you have a moment, do you mind having a quick look (it's a one-liner)? |
Regardless I think it should look down the visual tree for the first snappoint provider if direct content isnt it. |
The problem with that is there could be multiple snappoint providers in the scrollviewer descendants, even on the same level. |
@emmauss we could aim to assess if there's a unique Side question: in the current implementation, what is the benefit for the |
LayoutTransformControl is a decorator, the same as border. It's not a panel or an items control so it makes no sense to implement Also, parent controls aren't supposed to search their descendants for controls that implement an interface, unless they only searching a fixed short depth. They are notified of visual tree updates only when they themselves are added to the visual tree. Their descendants can change at anytime and they won't be notified. On the other hand, descendants are free to search up the visual tree for providers they can register to. That's what panels do with IScrollAnchorProvider, and what refresh visualizer does with refresh control's scrollviewer. They know when their position in the visual tree changes and can register/unregister when they want to. |
@emmauss makes a lot of sense. My question was more about what are the advantages of the approach I took here, i.e. passing the Also, would that make sense to handle private void OnScrollGestureInertiaStartingEnded(object? sender, ScrollGestureInertiaStartingEventArgs e)
{
var scrollable = Content;
if (Content is ItemsControl itemsControl)
scrollable = itemsControl.Presenter?.Panel;
// Added logic:
else if (Content is Decorator decorator && decorator.Child is IScrollSnapPointsInfo s)
scrollable = s;
if (scrollable is not IScrollSnapPointsInfo)
return;
[...] |
We shouldn't be adding special behaviors thats not related to the primary function of a control. Only panels and scrolling controls should interact with IScrollSnapPointsInfo. Content controls should only render their content and apply whatever they were designed to do, i.e. Border applies a border, LayoutTransformControl applies a transforms, etc. Telling others what kind of content they hosting isn't their role. |
The better option would be for any IScrollSnapPointsInfo to search up its ancestors for a ScrollViewer like control and register itself as snap point source. |
@emmauss thanks for the insight here. Not sure if the Avalonia team has a plan to address that in the short-term, but I'm happy to try doing a PR. Do you mind pointing me towards classes that implement this kind of patern ("search up its ancestors for a control and register itself")? |
VirtualizingStackPanel searches for a |
Describe the bug
This is a follow up on my previous issue #17460 (old PR #17461)
When using a
ScrollViewer
for anItemsPresenter
inside aLayoutTransformControl
, theScrollViewer
'sExtent
property is not correctly computed.This is visible as the vertical scrollbar is not correct (assumes the
ItemsPresenter
is smaller than it actually is), see below:When removing the
LayoutTransformControl
, the Extend is correct, as is the scrollbar:I've created a repos to reproduce the issue: https://github.com/BobLd/ScrollBarSizeIssue and below are some metrics from the app:
No layout transform:
With layout transform:
To Reproduce
See https://github.com/BobLd/ScrollBarSizeIssue
If you run the app as is, you will see the problem (incorrect behaviour).
If you remove the
LayoutTransformControl
inTestItemsControl.axaml
, the behaviour will be correct.Expected behavior
The
ScrollViewer
Extent should be correct even if it contains aLayoutTransformControl
Avalonia version
11.2.3
OS
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: