Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange issue - mouse click in popup is getting captured by control underneath

Tags:

wpf

I'm displaying a Popup in response to a button click (popup.IsOpen = true;). The popup contains a ComboBox, and when I click an item in the combobox, one of the things the SelectionChanged event does is to hide the popup.

The Popup appears over a DataGrid that I also have on my page, and I'm finding that the mouse-click on the combobox is also being picked up by a MouseUp event that I've got on the DataGrid. Any idea what's going on?

like image 898
Andrew Stephens Avatar asked Feb 22 '13 15:02

Andrew Stephens


1 Answers

The MouseUp Event has a routing strategy of type Bubbling. Events that use this type of strategy get passed up the chain to parent controls. Since the Popup is a child of the DataGrid, the event will "bubble" up to the DataGrid. If you would rather the event not bubble, you can try using PreviewMouseUp, which has a Tunneling routing strategy, and will "tunnel" down the chain to child controls. Here is a decent overview of Routing Strategies.

like image 136
Mash Avatar answered Nov 02 '22 04:11

Mash