I have a graph with a polyline contained in a canvas. I would like to set the stroke of the polyline, starting with the color at the bottom and ending with another color at the top. I tried with this xaml:
<Polyline StrokeThickness="2"> <Polyline.Stroke> <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0"> <GradientStop Color="Blue" Offset="0" /> <GradientStop Color="Cyan" Offset="1" /> </LinearGradientBrush> </Polyline.Stroke> </Polyline>
This way it works, but the height of the gradient is equal to the height of the polyline. I mean, if I have a polyline that goes from the bottom of the canvas to its top, the gradient is applied across the entire height of the canvas. If I instead have a horizontal polyline, the gradient applies to its thickness.
I would like to have a gradient height equal to the height of the canvas, regardless of the height of the polyline.
How can I achieve this?
source share