Jamie Penney
Jamie Penney

Reputation: 9522

MouseCapture prevents all mouse based triggers from firing in WPF

I am using CaptureMouse() during a drag and drop operation to make sure I don't miss the MouseUp event, but this seems to prevent any mouse events reaching any other objects on my Canvas. This means that my IsMouseOver based triggers don't work, but I need them to indicate valid locations where the object can be dropped.

Am I doing this wrong, or is there a way of making sure everything on my Canvas still gets mouse events?

Upvotes: 1

Views: 963

Answers (1)

Todd White
Todd White

Reputation: 7880

Are the elements part of the SubTree of your canvas? or outside of the canvas? If they are within then you could probably use the Capture method that takes a CaptureMode.

Mouse.Capture(elementToCapture, CaptureMode.SubTree);

Alternatively, you should look at the DragDrop class and consider using the Drop event instead?

Upvotes: 5

Related Questions