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

I need to trigger an event when the left mouse button is released. I 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 one

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

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

+5
source share
3 answers

Enter the event name EventTrigger MouseLeftButtonUp ".

+8
source

I'm not too familiar with C #, but as far as I know, MouseBinding does not allow you to support mouse actions, not just the mouse. Take a look here

0
source

Why don't you try:

 private void btn_MouseUp(object sender, MouseEventArgs e) { /////WHAT YOU WANT THE BUTTON TO DO///// } 

If you need to know more about mouse events, enter HERE

0
source

Source: https://habr.com/ru/post/1200881/


All Articles