簡體   English   中英

Xamarin Forms UWP 更改垂直滾動條顏色

[英]Xamarin Forms UWP change vertical scrollbar color

I have a Xamarin Forms app which I'd like to change the UWP vertical scrollbar color (currently it uses the default windows color).

我該怎么做?

也許可以從 UWP App.xamlApp.xaml.cs以某種方式做到這一點?

也許可以從 UWP App.xaml 或 App.xaml.cs 以某種方式做到這一點

當然,您可以編輯 UWP 原生 ScrollBar 樣式來更新默認 ScrollBar 界面。 下面的代碼正在更新拇指的顏色。 您可以將以下內容直接復制到您的 uwp app.xaml 文件中

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

接受的解決方案有效。 我有點卡住了,所以把它放在那里(事后看來很明顯)。 您需要編輯 UWP 項目中的 app.xaml,而不是共享代碼項目中的 app.xaml。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM