wpf storyboard停止按钮命令执行 [英] wpf storyboard stops button command from executing

查看:57
本文介绍了wpf storyboard停止按钮命令执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有以下代码



 <  按钮   命令  =  {Binding ResetAll}     样式  =  {StaticResource GlassButtonBlue}     宽度  =  65   < span class =code-attribute>高度  =  65    Canvas.Left   =  347 >  
< Button.Content >
< span class =code-keyword>< 图片 Source = / MainHub; component / Images / Update.png IsHitTestVisible = False / >
< / Button.Content >
< Button.Triggers >
< EventTrigger RoutedEvent = LostMouseCapture >
< BeginStoryboard 故事板 = {StaticResource Reverse_ClickTwice} / >
< / EventTrigger >
< / Button.Triggers >
< /按钮 >







只是在屏幕上移动一些按钮并隐藏当前按钮。但是,当前按钮的命令并不总是触发。有时动画会发生,但单击按钮时不会触发单击事件或命令。谁能告诉我为什么会这样呢?我被告知这可能是因为事件发生的顺序,但我不确定。



谢谢!

解决方案

找到了! :)将触发事件更改为''

 LostMouseCapture 

'',以便命令首先触发,然后故事板执行。



 <   Button.Triggers  >  
< EventTrigger RoutedEvent = LostMouseCapture >
< BeginStoryboard 故事板 = {StaticResource SingleClick} / >
< / EventTrigger >
< / Button.Triggers >


Hi guys and girls, I have the following code

<Button Command="{Binding ResetAll}"  Style="{StaticResource GlassButtonBlue}"  Width="65" Height="65" Canvas.Left="347">
                 <Button.Content>
                     <Image Source="/MainHub;component/Images/Update.png" IsHitTestVisible="False"/>
                 </Button.Content>
                 <Button.Triggers>
                     <EventTrigger RoutedEvent="LostMouseCapture">
                         <BeginStoryboard Storyboard="{StaticResource Reverse_ClickTwice}"/>
                     </EventTrigger>
                 </Button.Triggers>
             </Button>




which just moves some buttons around on my screen and hides the current one. However, the command of the current button does not always fire. Sometimes the animation happens, but neither a click event or a command is fired when the button is clicked. Can anyone tell me why this would happen? I''ve been told it could be because of the order of events that fire but i''m not sure.

Thanks!

解决方案

Found it ! :) changed the event of the trigger to ''

LostMouseCapture

'' so that the command fires first and then the storyboard executes.

<Button.Triggers>
   <EventTrigger RoutedEvent="LostMouseCapture">
      <BeginStoryboard Storyboard="{StaticResource SingleClick}"/>                          
   </EventTrigger>
</Button.Triggers>


这篇关于wpf storyboard停止按钮命令执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆