-1

I've added a MouseDown event to my window. In this window I've several Buttons with Click events.

The problem is, that the MouseDown event from my window is also activated, when I click on one of my buttons.

How can I solve this problem?

Draken
  • 3,134
  • 13
  • 34
  • 54
Graphix
  • 3
  • 1
  • 1
  • 5
    The event is bubbling up to your window. Look for event tunneling and bubbling, you have to set e.Handled = true inside your click event handler so that the event does not bubble further. – Raviraj Palvankar Sep 06 '18 at 10:45
  • Possible duplicate of [Difference between Bubbling and Tunneling events](https://stackoverflow.com/questions/16736444/difference-between-bubbling-and-tunneling-events) – kabanus Sep 06 '18 at 11:47

1 Answers1

0

One Approach was already mentioned by Raviraj Palvankar in the comments of your question, I'm just going to write it out: Your button recognizes that the mouse-down Event has been triggered, the problem is, that you don't "exit" this "state" For short: There is an option called

e.Handled = true;

This will "clear" the event, so it won't trigger again Also useful for textinput method when you want to validate the pressed key but don't want the key to be displayed in the textbox

Shmosi
  • 322
  • 2
  • 17