[英]Xamarin Forms: custom progressbar renderer for UWP and win8.1
嗨,我正在使用 PCL 项目在 XAMARIN 表单中开发一个应用程序。 因为我正在使用进度条。 我需要更改填充区域的颜色。 为此,我尝试了颜色属性,但它没有显示为进度条找到颜色属性。 因此,为此我为进度条创建了一个自定义渲染器,以便我可以设置它的颜色,但我无法在 UWP 中找到任何属性来更改它的颜色。 任何人都可以建议我一种方法来更改所有平台的填充区域颜色,专门针对 UWP 和 Windows 8.1。
更新:您是否尝试为 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.