I have a Xamarin Forms app which I'd like to change the UWP vertical scrollbar color (currently it uses the default windows color).
How can I do it?
Maybe is possible to do it from UWP App.xaml
or App.xaml.cs
somehow?
CodePudding user response:
Maybe is possible to do it from UWP App.xaml or App.xaml.cs somehow
Sure, you could edit the UWP native ScrollBar style to update the default ScrollBar interface. And the following code is updating the thumb's color. you could copy the following to your uwp app.xaml file directly
<Application.Resources>
<ResourceDictionary>
<SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="RoyalBlue" />
<SolidColorBrush x:Key="ScrollBarPanningThumbBackground" Color="RoyalBlue" />
<SolidColorBrush x:Key="ScrollBarThumbFillPressed" Color="RoyalBlue" />
<SolidColorBrush x:Key="ScrollBarThumbFillPointerOver" Color="RoyalBlue" />
<SolidColorBrush x:Key="ScrollBarThumbFill" Color="RoyalBlue" />
<!--The default scrollbar is too long to share here, please go to UWP generic.xaml to find the defalut `ScrollBar` style and edit base on that.-->
<Style TargetType="ScrollBar">
<Setter Property="MinWidth" Value="{ThemeResource ScrollBarSize}" />
<Setter Property="MinHeight" Value="{ThemeResource ScrollBarSize}" />
<Setter Property="Background" Value="{ThemeResource ScrollBarBackground}" />
<Setter Property="Foreground" Value="{ThemeResource ScrollBarForeground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ScrollBarBorderBrush}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
........
</ResourceDictionary>
</Application.Resources>