我在图像上创建了一个命名样式,并在该样式中将 MouseDown 事件的 EventBinding 设置为 ResourceDictionary 代码隐藏处的处理程序,效果很好。当我使用如下图像时:
<Style TargetType="{x:Type Image}" x:Key="ImageStyle">
<EventSetter Event="MouseDown" Handler="Image_MouseDown"/>
</Style>
<!---->
<Image Style="{StaticResource ImageStyle}">
<Image.InputBindings>
<MouseBinding Command="Save" MouseAction="LeftClick"/>
</Image.InputBindings>
</Image>
它会导致样式化的 MouseDown 事件绑定不起作用。