WPF 颜色渐变
一、按钮颜色渐变(从上而下)
<Button Height="100" Width="200">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFC5D2F3" Offset="0"/>
<GradientStop Color="#FF042476" Offset="1"/>
</LinearGradientBrush>
</Button.Background>
</Button>
效果:
二、矩形颜色渐变(从左而右)
<Rectangle Canvas.Left="51" Canvas.Top="187" Height="101" Name="rectangle2" Stroke="Black" Width="325">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#FF6B8FF0" Offset="0.5"/>
<GradientStop Color="#FF040A4B" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
效果:
三、由外向内渐变
<Grid>
<Grid.Background>
<RadialGradientBrush Center="0.5,0.7" GradientOrigin="0.5,0.7" RadiusX="0.8" RadiusY="0.8">
<GradientStop Color="#FFA4B3D3"/>
<GradientStop Color="#FF302C5D" Offset="0.952"/>
<GradientStop Color="#FF96AAD4" Offset="0.162"/>
</RadialGradientBrush>
</Grid.Background>
</Grid>
效果:
转载: