diff --git a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.iOS.cs index 3f05d8e7db06..292863e1297c 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.iOS.cs @@ -85,10 +85,17 @@ private bool ChangeViewNative(double? horizontalOffset, double? verticalOffset, var success = desiredOffsets == clampedOffsets; if (!success && IsArrangeDirty) { + // If the the requested offsets are out-of - bounds, but we actually does have our final bounds yet, + // we allow to set the desired offsets. If needed, they will then be clamped by the OnAfterArrange(). + // This is needed to allow a ScrollTo before the SV has been layouted. + _pendingChangeView = (horizontalOffset, verticalOffset, disableAnimation); + _scrollableContainer.SetContentOffset(desiredOffsets, !disableAnimation); + } + else + { + _scrollableContainer.SetContentOffset(clampedOffsets, !disableAnimation); } - - _scrollableContainer.SetContentOffset(desiredOffsets, !disableAnimation); if(zoomFactor is { } zoom) { diff --git a/src/Uno.UI/UI/Xaml/UIElement.debugging.cs b/src/Uno.UI/UI/Xaml/UIElement.debugging.cs index ba58c59e13d9..94e6a7451d47 100644 --- a/src/Uno.UI/UI/Xaml/UIElement.debugging.cs +++ b/src/Uno.UI/UI/Xaml/UIElement.debugging.cs @@ -24,17 +24,13 @@ using Windows.UI.Core; using System.Text; -#if __IOS__ -using UIKit; -#endif - #if XAMARIN_ANDROID using View = Android.Views.View; using ViewGroup = Android.Views.ViewGroup; using Font = Android.Graphics.Typeface; using Android.Graphics; using DependencyObject = System.Object; -#elif XAMARIN_IOS +#elif __IOS__ using View = UIKit.UIView; using ViewGroup = UIKit.UIView; using UIKit;