FontFamily:指定图标字体资源文件;(推荐iconfont阿里矢量图标)
示例代码:
XML
<Style x:Key="MyIconButtonStyle" TargetType="Button">
<Setter Property="Width" Value="40" />
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="back" Background="Transparent">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="./Fonts/#iconfont"
FontSize="{Binding FontSize, RelativeSource={RelativeSource AncestorType=Button, Mode=FindAncestor}}"
Text="{Binding Content, RelativeSource={RelativeSource AncestorType=Button, Mode=FindAncestor}}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="back" Property="Background" Value="#FFFFFF" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="back" Property="Background" Value="#AAAAAA" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>