老实说,如果您使用的是 WPF,那么使用路径来制作“x”形状可能同样容易:
<Style x:Key="DeleteButtonStyle" TargetType="{x:Type Button}">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Name="Circle" Data="F1 M 0 7.5 A 7.5 7.5 0 1 1 15 7.5 A 7.5 7.5 0 1 1 0 7.5"/>
<Path Fill="White" Data="F1 M 7.5 6 L 10.5,3 12,4.5 9,7.5 12,10.5 10.5,12 7.5,9 4.5,12 3,10.5 6,7.5 3,4.5 4.5,3 Z"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" TargetName="Circle" Value="SlateGray"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Fill" TargetName="Circle" Value="DarkGray"/>
</Trigger>
<DataTrigger Binding="{Binding}" Value="{x:Null}">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ToolTip" Value="Delete This Item"/>
</Style>
只需将此样式应用于按钮,您就会得到一个即时的“删除”按钮!