diff --git a/src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.wasm.cs b/src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.wasm.cs index e36a2d144053..c7dd7e0a9c92 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.wasm.cs @@ -18,7 +18,7 @@ namespace Windows.UI.Xaml.Controls public partial class ScrollContentPresenter : ContentPresenter, IScrollContentPresenter { private ScrollBarVisibility _verticalScrollBarVisibility; - private ScrollBarVisibility _horizotalScrollBarVisibility; + private ScrollBarVisibility _horizontalScrollBarVisibility; internal Size ScrollBarSize { @@ -98,7 +98,7 @@ private void HandlePointerEvent(Input.PointerRoutedEventArgs e) ScrollBarVisibility IScrollContentPresenter.VerticalScrollBarVisibility { get => VerticalScrollBarVisibility; set => VerticalScrollBarVisibility = value; } internal ScrollBarVisibility VerticalScrollBarVisibility { - get { return _verticalScrollBarVisibility; } + get => _verticalScrollBarVisibility; set { if (_verticalScrollBarVisibility != value) @@ -113,12 +113,12 @@ internal ScrollBarVisibility VerticalScrollBarVisibility ScrollBarVisibility IScrollContentPresenter.HorizontalScrollBarVisibility { get => HorizontalScrollBarVisibility; set => HorizontalScrollBarVisibility = value; } internal ScrollBarVisibility HorizontalScrollBarVisibility { - get { return _horizotalScrollBarVisibility; } + get => _horizontalScrollBarVisibility; set { - if (_horizotalScrollBarVisibility != value) + if (_horizontalScrollBarVisibility != value) { - _horizotalScrollBarVisibility = value; + _horizontalScrollBarVisibility = value; SetClasses(HorizontalVisibilityClasses, (int)value); } } diff --git a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs index 640caca451dd..f57fae020379 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs @@ -761,7 +761,7 @@ private void UpdateComputedVerticalScrollability(bool invalidate) #if !UNO_HAS_MANAGED_SCROLL_PRESENTER // Support for the native scroll bars (delegated to the native _presenter). - _presenter.VerticalScrollBarVisibility = ComputeNativeScrollBarVisibility(visibility, mode, _verticalScrollbar); + _presenter.VerticalScrollBarVisibility = ComputeNativeScrollBarVisibility(scrollable, visibility, mode, _verticalScrollbar); if (invalidate && _verticalScrollbar is null) { InvalidateMeasure(); // Useless for managed ScrollBar, it will invalidate itself if needed. @@ -798,7 +798,7 @@ private void UpdateComputedHorizontalScrollability(bool invalidate) #if !UNO_HAS_MANAGED_SCROLL_PRESENTER // Support for the native scroll bars (delegated to the native _presenter). - _presenter.HorizontalScrollBarVisibility = ComputeNativeScrollBarVisibility(visibility, mode, _horizontalScrollbar); + _presenter.HorizontalScrollBarVisibility = ComputeNativeScrollBarVisibility(scrollable, visibility, mode, _horizontalScrollbar); if (invalidate && _horizontalScrollbar is null) { InvalidateMeasure(); // Useless for managed ScrollBar, it will invalidate itself if needed. @@ -835,12 +835,13 @@ private static bool ComputeIsScrollEnabled(double scrollable, ScrollBarVisibilit && visibility != ScrollBarVisibility.Disabled && mode != ScrollMode.Disabled; - private ScrollBarVisibility ComputeNativeScrollBarVisibility(ScrollBarVisibility visibility, ScrollMode mode, ScrollBar? managedScrollbar) - => mode switch + private ScrollBarVisibility ComputeNativeScrollBarVisibility(double scrollable, ScrollBarVisibility visibility, ScrollMode mode, ScrollBar? managedScrollbar) + => (scrollable, visibility, mode, managedScrollbar) switch { - ScrollMode.Disabled => ScrollBarVisibility.Disabled, - _ when managedScrollbar is null && Uno.UI.Xaml.Controls.ScrollViewer.GetShouldFallBackToNativeScrollBars(this) => visibility, - _ when visibility == ScrollBarVisibility.Disabled => ScrollBarVisibility.Disabled, + (_, _, ScrollMode.Disabled, _) => ScrollBarVisibility.Disabled, + (0, ScrollBarVisibility.Auto, _, null) => ScrollBarVisibility.Hidden, // If scrollable is 0, the managed scrollbar won't be realized, we prefer to hide the native one until we are sure! + (_, _, _, null) when Uno.UI.Xaml.Controls.ScrollViewer.GetShouldFallBackToNativeScrollBars(this) => visibility, + (_, ScrollBarVisibility.Disabled, _, _) => ScrollBarVisibility.Disabled, _ => ScrollBarVisibility.Hidden // If a managed scroll bar was set in the template, native scroll bar has to stay Hidden };