[英]Xamarin Forms: custom progressbar renderer for UWP and win8.1
Hi I am developing an app in XAMARIN FORMS using PCL project.嗨,我正在使用 PCL 项目在 XAMARIN 表单中开发一个应用程序。 In that I am using progressbar.
因为我正在使用进度条。 I need to change the color of filled area.
我需要更改填充区域的颜色。 For that I tried color property but it shows no color property found for progressbar.
为此,我尝试了颜色属性,但它没有显示为进度条找到颜色属性。 So for that I created an custom renderer for progressbar so that I can set its color but I am not able to find any property to change its color in UWP.
因此,为此我为进度条创建了一个自定义渲染器,以便我可以设置它的颜色,但我无法在 UWP 中找到任何属性来更改它的颜色。 Can anyone suggest me a way to change the filled area color for all platforms specially for UWP and windows 8.1.
任何人都可以建议我一种方法来更改所有平台的填充区域颜色,专门针对 UWP 和 Windows 8.1。
For android and ios I have used this 对于 android 和 ios 我已经使用了这个
Update: Did you try to create custom Renderer for UWP and change Foreground color?更新:您是否尝试为 UWP 创建自定义渲染器并更改前景色?
var pb = Element as Windows.UI.Xaml.Controls.ProgressBar();
pb.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
Also for UWP you can override default style for ProgressBar.同样对于 UWP,您可以覆盖 ProgressBar 的默认样式。 Just grab default style from here and replace Foreground value, for example:
只需从这里获取默认样式并替换 Foreground 值,例如:
<Setter Property="Foreground" Value="Red" />
Than put this style in App.xaml inside UWP specific project比将此样式放在 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>
Now all ProgressBar controls will use your custom color现在所有 ProgressBar 控件都将使用您的自定义颜色
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.