Skip to content

Commit fe8b659

Browse files
fix(tabview): Fix ScrollViewer-related issues
- ensure ScrollBar is correctly hidden in tab row - ensure increase/decrease buttons have correct initial visual state
1 parent 6964f22 commit fe8b659

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/Uno.UI.FluentTheme/Resources/PriorityDefault/TabView.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
88
xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)"
99
xmlns:local="using:Microsoft.UI.Xaml.Controls"
10+
xmlns:uno="using:Uno.UI.Xaml.Controls"
1011
xmlns:ios="http://platform.uno/ios"
1112
xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives">
1213

@@ -170,7 +171,10 @@
170171
</Style>
171172

172173
<Style x:Name="TabScrollViewerStyle" TargetType="ScrollViewer">
173-
<Setter Property="Template">
174+
<!--Uno workaround: ScrollBars are deliberately omitted from the style because they shouldn't appear-->
175+
<Setter Property="uno:ScrollViewer.ShouldFallBackToNativeScrollBars"
176+
Value="False"/>
177+
<Setter Property="Template">
174178
<Setter.Value>
175179
<ControlTemplate TargetType="ScrollViewer">
176180
<Border x:Name="Root"

src/Uno.UI.FluentTheme/themeresources.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:media="using:Microsoft.UI.Xaml.Media" xmlns:controls="using:Microsoft.UI.Xaml.Controls" xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives" xmlns:contract4Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,4)" xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:primitiveContract7Present="using:Microsoft.UI.Xaml.Controls.Primitives?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:contract4NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,4)" xmlns:wasm="http://uno.ui/wasm" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:unouwp="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Uno.WinUI,1)" xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:contract6Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,6)" xmlns:ios="http://platform.uno/ios" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
1+
<ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:media="using:Microsoft.UI.Xaml.Media" xmlns:controls="using:Microsoft.UI.Xaml.Controls" xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives" xmlns:contract4Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,4)" xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:primitiveContract7Present="using:Microsoft.UI.Xaml.Controls.Primitives?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)" xmlns:contract4NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,4)" xmlns:wasm="http://uno.ui/wasm" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:unouwp="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Uno.WinUI,1)" xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:contract6Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,6)" xmlns:uno="using:Uno.UI.Xaml.Controls" xmlns:ios="http://platform.uno/ios" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<ResourceDictionary.ThemeDictionaries>
33
<ResourceDictionary x:Key="Default">
44
<SolidColorBrush x:Key="SystemControlTransparentBrush" Color="Transparent" />
@@ -20108,6 +20108,8 @@
2010820108
</Setter>
2010920109
</Style>
2011020110
<Style x:Name="TabScrollViewerStyle" TargetType="ScrollViewer">
20111+
<!--Uno workaround: ScrollBars are deliberately omitted from the style because they shouldn't appear-->
20112+
<Setter Property="uno:ScrollViewer.ShouldFallBackToNativeScrollBars" Value="False" />
2011120113
<Setter Property="Template">
2011220114
<Setter.Value>
2011320115
<ControlTemplate TargetType="ScrollViewer">
@@ -21368,4 +21370,4 @@
2136821370
</Setter>
2136921371
</Style>
2137021372
<Style TargetType="controls:TwoPaneView" BasedOn="{StaticResource DefaultTwoPaneViewStyle}" />
21371-
</ResourceDictionary>
21373+
</ResourceDictionary>

src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public partial class TabView : Control
7676
private long m_listViewCanReorderItemsPropertyChangedRevoker;
7777
private long m_listViewAllowDropPropertyChangedRevoker;
7878

79+
private long m_ScrollViewerScrollableWidthPropertyChangedRevoker; // Uno workaround
80+
7981
public TabView()
8082
{
8183
m_dispatcherHelper = new DispatcherHelper(this);
@@ -396,6 +398,7 @@ private void UnhookEventsAndClearFields()
396398
{
397399
m_scrollViewer.Loaded -= OnScrollViewerLoaded;
398400
m_scrollViewer.ViewChanged -= OnScrollViewerViewChanged;
401+
m_scrollViewer.UnregisterPropertyChangedCallback(ScrollViewer.ScrollableWidthProperty, m_ScrollViewerScrollableWidthPropertyChangedRevoker); // Uno workaround
399402
}
400403

401404
if (m_scrollDecreaseButton != null)
@@ -557,6 +560,12 @@ ItemsPresenter GetItemsPresenter(ListView listView)
557560
{
558561
scrollViewer.Loaded += OnScrollViewerLoaded;
559562
}
563+
// Uno workaround: Since Loaded is called before measure, the increase/decrease button visibility is not initially set
564+
// properly unless we subscribe to ScrollableWidth changing.
565+
m_ScrollViewerScrollableWidthPropertyChangedRevoker = scrollViewer.RegisterPropertyChangedCallback(
566+
ScrollViewer.ScrollableWidthProperty,
567+
(_, __) => UpdateScrollViewerDecreaseAndIncreaseButtonsViewState()
568+
);
560569
}
561570
}
562571
}

src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@
174174
</Setter>
175175
</Style>
176176

177-
<Style x:Name="TabScrollViewerStyle" TargetType="ScrollViewer">
178-
<Setter Property="Template">
177+
<Style x:Name="TabScrollViewerStyle" TargetType="ScrollViewer">
178+
<!--Uno workaround: ScrollBars are deliberately omitted from the style because they shouldn't appear-->
179+
<Setter Property="uno:ScrollViewer.ShouldFallBackToNativeScrollBars"
180+
Value="False"/>
181+
<Setter Property="Template">
179182
<Setter.Value>
180183
<ControlTemplate TargetType="ScrollViewer">
181184
<Border x:Name="Root"

0 commit comments

Comments
 (0)