Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I trigger an event when the left mouse button gets released in WPF?

Tags:

c#

wpf

xaml

I need to trigger an event when the left mouse button gets released. I've tried this:

<i:Interaction.Triggers>
   <i:EventTrigger EventName="MouseClick" >
      <i:InvokeCommandAction Command="{Binding OnBarGroupChangeCommand}"    CommandParameter="{Binding ElementName=ReportsBarGroup, Path=Key}"  />
   </i:EventTrigger>
</i:Interaction.Triggers>

and this

        <igWPF:OutlookBarGroup.InputBindings>
            <MouseBinding MouseAction="LeftClick" 
                          Command="{Binding OnBarGroupChangeCommand}" CommandParameter="{Binding ElementName=ReportsBarGroup, Path=Key}"/>
        </igWPF:OutlookBarGroup.InputBindings>

These both work. The problem with both cases is that the event fires when the button gets pressed. I need it to fire only when the button gets released. The MouseBinding does not seem to support this. Is there a way to do this with Interaction? What is the best way to handle this? Thanks.

like image 722
KrisW Avatar asked Aug 21 '14 20:08

KrisW


1 Answers

Try EventTrigger event name "MouseLeftButtonUp".

like image 186
allen1 Avatar answered Oct 13 '22 01:10

allen1