0

Is there any particular reason why ListBox does not fire the MouseRightButtonUp event?

<ListBox x:Name="Users"
             ItemsSource="{Binding Users}"
             MouseRightButtonUp="MouseRightButtonUp" />
Fitzchak Yitzchaki
  • 9,095
  • 12
  • 56
  • 96

2 Answers2

0

When a routed event is not fired in your control it means a control which is deeper in the visual tree is "eating" the event by marking it as handled in the event chain. In your case I suspect it is the ScrollViewer inside the ListBox eating the event.

Murven
  • 2,377
  • 17
  • 23
0

here the answer taken from my previous comment ;)

I guess the problem is like Murven said, that the RightButtonUp event is handled by another control and is not getting to the ListBox. But if you add a MouseRightButtonDownHandler and just set e.handled = true in this handler, the MouseRightButtonUpHandler is called...

XAML:

<ListBox x:Name="Users" MouseRightButtonDown="downHandler" MouseRightButtonUp="upHandler"...>

Code Behind:

private void downHandler(object sender, MouseButtonEventArgs e) { e.Handled = true; }

BR,

TJ

TerenceJackson
  • 1,776
  • 15
  • 24