You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an item with a Stretch alignment is arranged in an area smaller than its size, Avalonia offsets the arrange bounds by half of a computed Margin (centering?). This moves the Control outside of the finalRect bounds up and to the left.
The WPF behavior is to instead treat this scenario as if the alignment were Left (and/or Top) instead of Stretch. In WPF's definitions of those, anyways.
(Gradient only to demonstrate the visual more clearly. ClipToBounds shows same behavior whether true or false.)
Expected behavior
I expect either WPF behavior or for this to be documented.
However, I think Avalonia's handling, especially Left alignment (not shown, but the visual gets clipped while staying in-place), is better than WPF's preference to prefer showing the margin more than the visual.
Avalonia version
11.1.0, 11.0.10
OS
Windows
Additional context
This leads to subtle bugs in components that are direct WPF ports, namely WrapPanel. See #16191 (comment)
I have locally been able to fix the problem with either approach: 1. customizing ArrangeCore to be more WPF-like (full margin offsetting instead of halving) or 2. direct fixes to WrapPanel. I need some feedback on this area before I can address the correct area.
The text was updated successfully, but these errors were encountered:
Describe the bug
When an item with a
Stretch
alignment is arranged in an area smaller than its size, Avalonia offsets the arrange bounds by half of a computed Margin (centering?). This moves the Control outside of thefinalRect
bounds up and to the left.Avalonia/src/Avalonia.Base/Layout/Layoutable.cs
Lines 671 to 691 in 413ff78
The WPF behavior is to instead treat this scenario as if the alignment were
Left
(and/orTop
) instead ofStretch
. In WPF's definitions of those, anyways.https://github.com/dotnet/wpf/blob/df3f4bf5568830adc3ed2d3da244ee7a17d551df/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkElement.cs#L4827-L4854
To Reproduce
(Gradient only to demonstrate the visual more clearly.
ClipToBounds
shows same behavior whether true or false.)Expected behavior
I expect either WPF behavior or for this to be documented.
However, I think Avalonia's handling, especially
Left
alignment (not shown, but the visual gets clipped while staying in-place), is better than WPF's preference to prefer showing the margin more than the visual.Avalonia version
11.1.0, 11.0.10
OS
Windows
Additional context
This leads to subtle bugs in components that are direct WPF ports, namely
WrapPanel
. See #16191 (comment)I have locally been able to fix the problem with either approach: 1. customizing
ArrangeCore
to be more WPF-like (full margin offsetting instead of halving) or 2. direct fixes toWrapPanel
. I need some feedback on this area before I can address the correct area.The text was updated successfully, but these errors were encountered: