Browse Source

Fix NativeControlHost not accounting for visual transforms in size calculation (#20785)

GetAbsoluteBounds() was using TransformToAABB only for the position but
then returning the untransformed Bounds.Size. This caused native controls
inside a Viewbox (or any parent with a visual transform) to be sized
incorrectly - the native window would appear at the right position but
at the wrong (unscaled) size.

Use the full transformed rect from TransformToAABB for both position and
size.

Fixes #13832

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
text_selector_zindex
mfkl 3 weeks ago
committed by GitHub
parent
commit
154bf35eaa
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      src/Avalonia.Controls/NativeControlHost.cs

4
src/Avalonia.Controls/NativeControlHost.cs

@ -151,8 +151,8 @@ namespace Avalonia.Controls
var transformToVisual = _currentRoot.RootVisual != null ? this.TransformToVisual(_currentRoot.RootVisual) : null;
if (transformToVisual == null)
return null;
var position = new Rect(default, bounds.Size).TransformToAABB(transformToVisual.Value).Position;
return new Rect(position, bounds.Size);
var transformedRect = new Rect(default, bounds.Size).TransformToAABB(transformToVisual.Value);
return transformedRect;
}
private void EnqueueForMoveResize()

Loading…
Cancel
Save