IsMouseOverとIsPressedイベントで異なるハイライト効果を持つ画像ボタンを作成したいと思います。私が使用しているコード:同じコントロールの複数のDataTriggerが機能しないのはなぜですか?
<Button Style="{StaticResource AccentedSquareButtonStyle}" x:Name="button" Background="Transparent" BorderThickness="0" Foreground="Transparent" Grid.Column="1" HorizontalAlignment="Left" Margin="142,-2,0,0" VerticalAlignment="Top" Width="75">
<Grid Background="Transparent">
<ContentControl>
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Setter Property="Content" Value="{StaticResource printIcon}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=IsPressed}" Value="True" >
<Setter Property="Content" Value="{StaticResource printIconClicked}"/>
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=IsMouseOver}" Value="True" >
<Setter Property="Content" Value="{StaticResource printIconHighlighted}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</Grid>
</Button>
私は別に DataTriggersを使用する場合、コードのみ動作しますが、この形式でのみマウスオーバーハイライトする効果が使用されています。私はMahAppsフレームワークを使用しています。 私は何が間違っていますか?
データ・トリガ場合は順番を入れ替えます。 DataTriggersのポジションを逆転させると機能しますが、私には理由が分かりません。 –