Description
Describe the bug
This is a follow up on my previous issue #17460 (old PR #17461)
When using a ScrollViewer
for an ItemsPresenter
inside a LayoutTransformControl
, the ScrollViewer
's Extent
property is not correctly computed.
<ScrollViewer Name="PART_ScrollViewer"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Focusable="True"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsScrollInertiaEnabled="True">
<LayoutTransformControl Name="PART_LayoutTransformControl"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ClipToBounds="True">
<ItemsPresenter Name="PART_ItemsPresenter"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
ItemsPanel="{TemplateBinding ItemsPanel}"/>
</LayoutTransformControl>
</ScrollViewer>
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:
<ScrollViewer Name="PART_ScrollViewer"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Focusable="True"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsScrollInertiaEnabled="True">
<ItemsPresenter Name="PART_ItemsPresenter"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
ItemsPanel="{TemplateBinding ItemsPanel}"/>
</ScrollViewer>
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:
- Grid
- Bounds 0, 0, 1585.3333333333333, 907.3333333333334
- ScrollViewer
- Bounds 0, 0, 1585.3333333333333, 907.3333333333334
- DesiredSize 204, 907.3333333333334
- Extent 204, 44844
- ItemsPresenter
- Bounds 690.6666666666666, 0, 204, 44844
- DesiredSize 204, 44844
With layout transform:
- Grid
- Bounds 0, 0, 1585.3333333333333, 907.3333333333334
- ScrollViewer
- Bounds 0, 0, 1585.3333333333333, 907.3333333333334
- DesiredSize 204, 907.3333333333334
- Extent 204, 3912 <- Not correct
- LayoutTransformControl
- Bounds 690.6666666666666, 0, 204, 3912
- DesiredSize 204, 3912
- ItemsPresenter
- Bounds 0, 0, 204, 3912
- DesiredSize 204, 3912
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
in TestItemsControl.axaml
, the behaviour will be correct.
Expected behavior
The ScrollViewer
Extent should be correct even if it contains a LayoutTransformControl
Avalonia version
11.2.3
OS
No response
Additional context
No response