Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top