We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This issue will occur when DragSource is Listbox which SelectionMode is Extend.
For example, there are 100 items in Listbox.
[Expect Result] 7th item ~ 10th item will be selected
[Actual Result] only 7th item is selected.
After step 3, if shift + click any item, the result is not the same as in windows file explorer.
DragDrop.DragSource_PreviewMouseLeftButtonUp { ... if (itemsControl != null && m_DragInfo != null && m_ClickSupressItem == m_DragInfo.SourceItem) { if ((Keyboard.Modifiers & ModifierKeys.Control) != 0) { itemsControl.SetItemSelected(m_DragInfo.SourceItem, false); } else { itemsControl.SetSelectedItem(m_DragInfo.SourceItem); } } ... } ItemsControlExtensions.SetSelectedItem { ... } else if (itemsControl is ListBox) { ((ListBox)itemsControl).SelectedItem = null; ((ListBox)itemsControl).SelectedItem = item; } ... }
I modify the code to
DragDrop.DragSource_PreviewMouseLeftButtonUp { ... if ((Keyboard.Modifiers & ModifierKeys.Control) != 0) { itemsControl.SetItemSelected(m_DragInfo.SourceItem, false); } else if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { object selecteditem = null; foreach (var item in itemsControl.GetSelectedItems()) { selecteditem = item; break; } if (selecteditem != null) { itemsControl.SetSelectedItem(selecteditem); if (selecteditem != m_DragInfo.SourceItem) { bool selectflag = false; object startitem = null, enditem = null; foreach (var item in itemsControl.Items) { if (item == m_DragInfo.SourceItem || item == selecteditem) { selectflag = true; if (null == startitem) startitem = item; else enditem = item; } if (itemsControl.GetItemSelected(item) != selectflag) itemsControl.SetItemSelected(item, selectflag); if (true == selectflag) { if (enditem == item) selectflag = false; } } } } } else { itemsControl.SetSelectedItem(m_DragInfo.SourceItem); } ... } ItemsControlExtensions.SetSelectedItem { ... } else if (itemsControl is ListBox) { SelectionMode mode = ((ListBox)itemsControl).SelectionMode; try { // change SelectionMode for UpdateAnchorAndActionItem ((ListBox)itemsControl).SelectionMode = SelectionMode.Single; ((ListBox)itemsControl).SelectedItem = null; ((ListBox)itemsControl).SelectedItem = item; } finally { ((ListBox)itemsControl).SelectionMode = mode; } }... }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This issue will occur when DragSource is Listbox which SelectionMode is Extend.
For example, there are 100 items in Listbox.
[Expect Result]
7th item ~ 10th item will be selected
[Actual Result]
only 7th item is selected.
After step 3, if shift + click any item, the result is not the same as in windows file explorer.
I modify the code to
The text was updated successfully, but these errors were encountered: