views:

314

answers:

1

In Silverlight (version 3 preview), I want to create a Line with different solid colors, so no gradients between colors.

Basically I want to do the following:

<Line X1="0" X2="500" StrokeThickness="10">
<Line.Stroke>
 <LinearGradientBrush>
  <GradientStop Color="Blue" Offset="0.5" />
  <GradientStop Color="Red" Offset="1"/>
 </LinearGradientBrush>
</Line.Stroke>
</Line>

But with a discrete change in color, and not the gradual change from blue to red

I wonder if this is possible without resorting to using multiple lines?

+1  A: 

What you're looking for is this

<Line.Stroke>
    <LinearGradientBrush>
            <GradientStop Color="Blue" Offset="0.5" />
         <GradientStop Color="Red" Offset="0.5" />
     </LinearGradientBrush>
</Line.Stroke>

By setting the stops on top of each other they don't have space in which to transition from the one to the other.

Hope this helps.

Graeme Bradbury
Ah it's that simple, but would've never (well maybe not never) figured it out myself, thanks!
eriksmith200