Sonali
Sonali

Reputation: 2273

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

Hi I am developing an app in XAMARIN FORMS using PCL project. 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. Can anyone suggest me a way to change the filled area color for all platforms specially for UWP and windows 8.1.

For android and ios I have used this

Upvotes: 1

Views: 1830

Answers (1)

Ros Haitovich
Ros Haitovich

Reputation: 151

Update: Did you try to create custom Renderer for UWP and change Foreground color?

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. Just grab default style from here and replace Foreground value, for example:

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

Than put this style in App.xaml inside UWP specific project

<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

Upvotes: 1

Related Questions