首页 > 代码库 > wpf image button样式

wpf image button样式

1:image button样式

<Style x:Key="Button.File" TargetType="Button">
  <Setter Property="Cursor" Value="http://www.mamicode.com/Hand"></Setter>
  <Setter Property="Template" >
    <Setter.Value>
      <ControlTemplate TargetType="Button">
        <Image Name="FileImage" Source="/程序集名称;component/images/file.png"/>
        <ControlTemplate.Triggers>
          <Trigger Property="IsMouseOver" Value="http://www.mamicode.com/True">
            <Setter TargetName="FileImage" Property="Source" Value="http://www.mamicode.com/程序集名称;component/images/file_over.png"/>
          </Trigger>
        </ControlTemplate.Triggers>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

2:使用image button样式

<Button Style="{StaticResource Button.File}" Height="30" Width="30" VerticalAlignment="Center" HorizontalAlignment="Center"></Button>

wpf image button样式