Hey all,
I'm working in WPF, but since this question is all about the code behind it makes sense to post it here.
I need to make area gradient using the System.Windows.Media namespace. Essential it would be a LinearGradient in both the horizontal and vertical directions simultaneously.
I have this code that produces the image below...
VB.Net Code:
Dim br As New LinearGradientBrush() Dim startP As New Point(0, 0.5) Dim endP As New Point(1, 0.5) br.StartPoint = startP br.EndPoint = endP br.GradientStops.Add(New GradientStop(Colors.Transparent, 0.0)) br.GradientStops.Add(New GradientStop(Colors.Red, 0.2)) br.GradientStops.Add(New GradientStop(Colors.Red, 0.8)) br.GradientStops.Add(New GradientStop(Colors.Transparent, 1)) _rectangle.Fill = br
I don't know how to draw the gradient once, then rotate it and redraw it again without covering the first.
If I were in the System.Drawing namespace I would create 4 triangles paths in the rectangle each rotated by 90 degrees and fill them with a gradient to produce the results. Being new to the Media namespace however, I don't see how to create a path like this.
Any one know how to create a area gradient like what I describe?
(VS2019 btw)




Reply With Quote