WPF(颜色突变)
我们知道可以用LinearGradientBrush实现颜色的渐变,如下图,从Red渐变到Blue:
<Border Grid.Row="1" BorderBrush="Black" BorderThickness="5" CornerRadius="20" >
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Blue" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
但是如何做到颜色的突变,就时从Red直接变为Blue呢???
还是利用 LinearGradientBrush,但是要利用4个渐变点:
<Border Grid.Row="1" BorderBrush="Black" BorderThickness="5" CornerRadius="20" >
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Red" Offset="0.5"/>
<GradientStop Color="Blue" Offset="0.5"/>
<GradientStop Color="Blue" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>