将cursor属性设置为两个值的手(即.true和false)

时间:2014-12-10 10:20:14

标签: wpf

在我的风格中,我想将两个值的光标值设置为Hand,对于true和false。

有没有办法设置它?

<Style TargetType="Image">
  <Setter Property="Source" Value="{StaticResource SOff}"/>
     <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
          <Setter Property="Cursor" Value="Hand" />
        </Trigger>                                       
        <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button},UpdateSourceTrigger=PropertyChanged}" Value="True">
          <Setter Property="Source" Value="{StaticResource SOff}" />
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button},UpdateSourceTrigger=PropertyChanged}" Value="False">
          <Setter Property="Source" Value="{StaticResource SOn}" />
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </Image.Style>
</Image> 

1 个答案:

答案 0 :(得分:0)

正如评论中所指出的,您不需要任何此行为的触发器。只需在样式上设置cursor属性即可。

<Setter Property="Cursor" Value="Hand"/>