New to Telerik UI for WPF? Download free 30-day trial

Drop event not fired

Environment

Product Version 2019.2.618
Product RadListBox for WPF

Description

How to get the RadListBoxItem element under the mouse when DragDropManager.DragOver or DragDropManager.Drop is fired for RadListBox.

Solution

In the DragOver or Drop event handler, get the OriginalSource of the event arguments. This is the element under the mouse. From it, you can use the ParentOfType method to get the RadListBoxItem.

private void OnRadListBoxDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) 
{ 
    var elementUnderMouse = (FrameworkElement)e.OriginalSource; 
    var item = elementUnderMouse.ParentOfType<RadListBoxItem>();         
} 
Note that if you don't data bind the ItemsSource of RadListBox, the OriginalSource of the event arguments might be the RadListBoxItem itself.

See Also

In this article