WPF: clicking and dragging a ListBox selects other items

Simple question:

1) I click and hold the mouse in the ListBoxItem in the ListBox.
2) Now I drag the mouse over the next ListBoxItem in the list

Now he selects this new item. I would like to disable this. Therefore, the user must click an item to select it. Don't just drag it.

I have Single selection enabled.

Any ideas are welcome :)

+3
source share
2 answers

This is mainly for people like me who still need to know this.

majocha , , , MouseUp . , MouseEventArgs, , ? , WPF 2010 .

, WPF 4. MouseMove ListBox :

private void ListBox_MouseMove(object sender, MouseEventArgs e)
{
    if (e.LeftButton == MouseButtonState.Pressed)
        (sender as ListBox).ReleaseMouseCapture();
}

!

+2

, OnPreviewMouseMove . .

0

Source: https://habr.com/ru/post/1741269/


All Articles