WPF - Select ListBoxItem with LeftClick only

I have a ListBox with SelectionMode = "Multiple" that allows me to select multiple rows by clicking on the left or right mouse buttons. How can I restrict the selection to only the left mouse button click?

0


a source to share


1 answer


I think you need to write your own ListBox (Item), override

    protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnPreviewMouseRightButtonDown(e);
    }

      

or



    protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnMouseRightButtonDown(e);
    }

      

EventHandler and use your own ListBox (Item) in your xaml. Remember to call e.Handled = true; you can probably also use one of the more general mouse event handlers and check if the right mouse button was pressed and then call e.Handled.

+3


a source







All Articles