diff --git a/src/client/spark/view/Controls/DragDropItemsControl/DragDropListBox.xaml.cs b/src/client/spark/view/Controls/DragDropItemsControl/DragDropListBox.xaml.cs index e5986df2f..61881d4c7 100644 --- a/src/client/spark/view/Controls/DragDropItemsControl/DragDropListBox.xaml.cs +++ b/src/client/spark/view/Controls/DragDropItemsControl/DragDropListBox.xaml.cs @@ -49,6 +49,8 @@ namespace mbts.ui.controls }; } + public bool SelectItemOnDrop { get; set; } + private DragIndicatorAdorner _adorner; private IDisposable _drag_operation; @@ -56,9 +58,13 @@ namespace mbts.ui.controls protected override DependencyObject GetContainerForItemOverride() { var container = new DraggableListBoxItem(); - container.MouseEnter += (s, e) => _adorner.InvalidateVisual(); - container.MouseLeave += (s, e) => _adorner.InvalidateVisual(); + container.MouseEnter += on_mouse_changed; + container.MouseLeave += on_mouse_changed; + container.MouseMove += on_mouse_changed; return container; + // + void on_mouse_changed(object sender, MouseEventArgs e) => + _adorner.InvalidateVisual(); } protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { @@ -89,6 +95,8 @@ namespace mbts.ui.controls if (source != null && target != null) { CoerceValue(DragDropManagerProperty); DragDropManager.Drop(source, target.Content); + if (SelectItemOnDrop && target is ListBoxItem lbi) + lbi.SetCurrentValue(ListBoxItem.IsSelectedProperty, true); } }