<Window.Resources> <Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" BorderThickness="1"> <Border.BorderBrush> <!--MappingMode:1.Absolute,StartPoint和EndPoint的值是按照Border的实际大小进行坐标设置 2.RelativeToBoundingBox,StartPoint和EndPoint的值按照0,0和0,1进行设置 --> <LinearGradientBrush StartPoint="0,5" EndPoint="5,0" SpreadMethod="Repeat" MappingMode="Absolute"> <GradientStop Color="Red" Offset="0" /> <GradientStop Color="Transparent" Offset="0.5" /> <GradientStop Color="Red" Offset="1" /> </LinearGradientBrush> </Border.BorderBrush> </Border> <!--此方法也能显示文字 <ContentPresenter Content="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center" />--> <TextBlock Text="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid Name="grdRoot"> <Button Name="btnClick" Content="Click" Width="72" Height="24" /> </Grid>