簡體   English   中英

Xamarin Forms:用於 UWP 和 win8.1 的自定義進度條渲染器

[英]Xamarin Forms: custom progressbar renderer for UWP and win8.1

嗨,我正在使用 PCL 項目在 XAMARIN 表單中開發一個應用程序。 因為我正在使用進度條。 我需要更改填充區域的顏色。 為此,我嘗試了顏色屬性,但它沒有顯示為進度條找到顏色屬性。 因此,為此我為進度條創建了一個自定義渲染器,以便我可以設置它的顏色,但我無法在 UWP 中找到任何屬性來更改它的顏色。 任何人都可以建議我一種方法來更改所有平台的填充區域顏色,專門針對 UWP 和 Windows 8.1。

對於 android 和 ios 我已經使用了這個

更新:您是否嘗試為 UWP 創建自定義渲染器並更改前景色?

var pb = Element as Windows.UI.Xaml.Controls.ProgressBar();
pb.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);

同樣對於 UWP,您可以覆蓋 ProgressBar 的默認樣式。 只需從這里獲取默認樣式並替換 Foreground 值,例如:

<Setter Property="Foreground" Value="Red" />

比將此樣式放在 UWP 特定項目中的 App.xaml 中

<Application
    x:Class="Xamarin.Prism.UWP.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    RequestedTheme="Light">

    <Application.Resources>

        <!-- Default style for Windows.UI.Xaml.Controls.ProgressBar -->
        PUT YOUR MODIFIED STYLE HERE

    </Application.Resources>

</Application>

現在所有 ProgressBar 控件都將使用您的自定義顏色

暫無
暫無

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

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