Xamarin窗体UWP更改垂直滚动条颜色

bf1o4zei  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(130)

我有一个Xamarin表单应用程序,我想改变UWP垂直滚动条的颜色(目前它使用默认的窗口颜色)。
我该怎么做?
也许有可能从UWP App.xamlApp.xaml.cs以某种方式做到这一点?

ux6nzvsh

ux6nzvsh1#

也许可以从UWP App.xaml或App.xaml.cs中以某种方式完成
当然,您可以编辑UWP原生ScrollBar样式来更新默认的ScrollBar界面。

<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>
1aaf6o9v

1aaf6o9v2#

被接受的解决方案是可行的。我有点卡住了,所以把它放在那里(事后看来这是显而易见的)。您需要编辑UWP项目中的app.xaml,而不是共享代码项目中的app.xaml。

相关问题