开发者

MouseBinding overrides EventBindings in style

开发者 https://www.devze.com 2022-12-17 10:07 出处:网络
I created a named style on an image, and in the style I set an EventBinding for the MouseDown event to a handler at the ResourceDictionary\'s code-behind, it worked good.

I created a named style on an image, and in the style I set an EventBinding for the MouseDown event to a handler at the ResourceDictionary's code-behind, it worked good. When I use the image as the following:

<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>

It causes the styled MouseDown eventbinding not to work.


It's hard to say without the style code, but I suppose you're defining InputBindings property in that style, then the Image setting just override it. Whatever you set in the actual element XAML overrides whatever you define in that element's style.

If that's the case, there's no easy way to merge style properties with the actual properties.

HTH.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号