<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen">
<Grid>
<Button Width="120" Height="30">
<Button.Content>
<Rectangle Width="20" Height="20" Stroke="DarkBlue" >
<Rectangle.Fill>
<LinearGradientBrush>
<!-- 画笔起始点和终止点 -->
<LinearGradientBrush.StartPoint>
<Point X="0" Y="0"/>
</LinearGradientBrush.StartPoint>
<LinearGradientBrush.EndPoint>
<Point X="1" Y="1"/>
</LinearGradientBrush.EndPoint>
<!--- 画板颜色变化设置-->
<GradientStopCollection>
<GradientStop Offset="0.2" Color="LightBlue"/>
<GradientStop Offset="0.7" Color="DarkBlue"/>
<GradientStop Offset="1.0" Color="Blue"/>
</GradientStopCollection>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Button.Content>
</Button>
</Grid>
</Window>
改进后
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen">
<Grid>
<Button Width="120" Height="30">
<Button.Content>
<Rectangle Width="20" Height="20" Stroke="DarkBlue" >
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Offset="0.2" Color="LightBlue"/>
<GradientStop Offset="0.7" Color="DarkBlue"/>
<GradientStop Offset="1.0" Color="Blue"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Button.Content>
</Button>
</Grid>
</Window>