diff --git a/src/Uno.UI/UI/Xaml/Internal/Scaling/RootScale.mux.cs b/src/Uno.UI/UI/Xaml/Internal/Scaling/RootScale.mux.cs index 734fc97062f3..045d6a7fcab4 100644 --- a/src/Uno.UI/UI/Xaml/Internal/Scaling/RootScale.mux.cs +++ b/src/Uno.UI/UI/Xaml/Internal/Scaling/RootScale.mux.cs @@ -136,6 +136,9 @@ private void ApplyScale(bool scaleChanged) if (scaleChanged) { + // TODO Uno: This should not be done here + VisualTree.ContentRoot.CompositionTarget.OnRasterizationScaleChanged(GetEffectiveRasterizationScale()); + // TODO Uno: Reload images on scale change! //foreach (var displayListener in _displayListeners) //{ diff --git a/src/Uno.UI/UI/Xaml/Media/CompositionTarget.cs b/src/Uno.UI/UI/Xaml/Media/CompositionTarget.cs index b4367d41cead..49a7a0fb45e8 100644 --- a/src/Uno.UI/UI/Xaml/Media/CompositionTarget.cs +++ b/src/Uno.UI/UI/Xaml/Media/CompositionTarget.cs @@ -10,15 +10,12 @@ namespace Microsoft.UI.Xaml.Media; public partial class CompositionTarget : ICompositionTarget { private Visual _root; - private double _rasterizationScale; + private double? _rasterizationScale; private EventHandler _rasterizationScaleChanged; internal CompositionTarget(ContentRoot contentRoot) { ContentRoot = contentRoot; - var xamlRoot = contentRoot.GetOrCreateXamlRoot(); - _rasterizationScale = xamlRoot.RasterizationScale; - xamlRoot.Changed += XamlRoot_Changed; } event EventHandler ICompositionTarget.RasterizationScaleChanged @@ -39,7 +36,7 @@ internal Visual Root } } - double ICompositionTarget.RasterizationScale => _rasterizationScale; + double ICompositionTarget.RasterizationScale => _rasterizationScale ?? 1.0; public static Compositor GetCompositorForCurrentThread() => Compositor.GetSharedCompositor(); @@ -50,12 +47,9 @@ void ICompositionTarget.TryRedirectForManipulation(PointerPoint pointerPoint, In #endif } - private void XamlRoot_Changed(XamlRoot sender, XamlRootChangedEventArgs args) + internal void OnRasterizationScaleChanged(double rasterizationScale) { - if (ContentRoot.XamlRoot.RasterizationScale != _rasterizationScale) - { - _rasterizationScale = ContentRoot.XamlRoot.RasterizationScale; - _rasterizationScaleChanged?.Invoke(this, EventArgs.Empty); - } + _rasterizationScale = rasterizationScale; + _rasterizationScaleChanged?.Invoke(this, EventArgs.Empty); } }