alan smith
alan smith

Reputation: 27

Progressbar with multiple colors WPF

i'm trying to make my progressbar look like this:

enter image description here

enter image description here

But i have this instead:

enter image description here

This is the code i have (i created a style for the progressbar with the property "fill" of the indicator):

<Rectangle x:Name="Indicator"  >
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0,0" StartPoint="1,0">
                                        <GradientStop Color="Red" Offset="0"/>
                                        <GradientStop Color="Yellow" Offset="0.5"/>
                                        <GradientStop Color="Green" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>


                            </Rectangle>

Upvotes: 0

Views: 540

Answers (1)

Mark Feldman
Mark Feldman

Reputation: 16119

Welcome to SO!

Just set that indicator's width to the same as that of the parent ProgressBar:

<Rectangle x:Name="Indicator" Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=ProgressBar}}">

Simple!

Upvotes: 1

Related Questions