0

我在图像上创建了一个命名样式,并在该样式中将 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 事件绑定不起作用。

4

1 回答 1

0

没有样式代码很难说,但我想您正在InputBindings以该样式定义属性,然后Image设置只是覆盖它。您在实际元素 XAML 中设置的任何内容都会覆盖您在该元素的样式中定义的任何内容。

如果是这种情况,就没有简单的方法将样式属性与实际属性合并。

HTH。

于 2010-01-14T05:41:46.503 回答