Problem with a chart with a polyline and a LinearGradientBrush
Posted
by Maurizio Reginelli
on Stack Overflow
See other posts from Stack Overflow
or by Maurizio Reginelli
Published on 2010-04-10T14:55:37Z
Indexed on
2010/04/10
15:03 UTC
Read the original article
Hit count: 464
I have a graph with a polyline contained into a canvas. I would like to set the stroke of the polyline starting from a color at the bottom and ending to another color on 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>
In 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 which goes from the bottom of the canvas to its top, the gradient is applied over the entire height of the canvas. If I have instead a horizontal polyline, the gradient is applied to its thickness.
I would like to have a gradient height equal to the canvas height, independently from the polyline height.
How can I achieve this?
© Stack Overflow or respective owner