我的WPF应用程序有多个按钮,支持多点触控,但不会将按下的样式应用于按下的按钮。更具体一点:
注意:按钮是同一个类的两个实例,并且在按下一次时正常工作。代码非常简单:
<Button Focusable="False" Style="{DynamicResource ButtonStyle}" Grid.Column="{Binding GridColumn}" Grid.Row="{Binding GridRow}" Margin="{Binding Margin}" Width="{Binding Width}" Height="{Binding Height}" Visibility="{Binding Visibility}" Stylus.IsPressAndHoldEnabled="False" Stylus.IsFlicksEnabled="False" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="TouchDown">
<cmd:EventToCommand Command="{Binding ButtonDownCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="TouchUp">
<cmd:EventToCommand Command="{Binding ButtonUpCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
应用的风格:
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter TargetName="glass" Property="Effect" Value="{StaticResource PressedShadow}"/>
<Setter TargetName="glass" Property="Margin" Value="20"/>
<Setter TargetName="blink" Property="Effect" Value="{StaticResource PressedShadow}"/>
<Setter TargetName="blink" Property="Margin" Value="20"/>
</MultiDataTrigger>
想法?