ListBox does not fire MouseRightButtonUp event
Is there a开发者_高级运维ny particular reason why ListBox does not fire the MouseRightButtonUp event?
<ListBox x:Name="Users"
ItemsSource="{Binding Users}"
MouseRightButtonUp="MouseRightButtonUp" />
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
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.
精彩评论