In WPF, is there a way to draw a line (in any orientation) that blends from one colour to another?
For example, I want to draw a line from point A to point B, where A is Red and B is Black. The line could be vertical, horizontal, or any orientation.
I have tried using a LinearGradientBrush, but this requires you to set an angle or Start/End positions. This won't work for me as I need to be able to draw the line at any two points in any orientation and still get it to blend. I could in theory compute the angle (or Start/End positions) for the LinearGradientBrush for each line and update it when ever the points of the line changes, but this wouldn't be ideal and would be an expensive operation for the number of lines I plan on drawing.
RadialGradientBrush also doesn't seem to help.
This following
LinearGradientBrush
"blends" from red to black regardless of theWidth
of theGrid
element: