Search code examples
wpfrouted-events

Routed event handlers drag drop information


If I register a class handler like so:

EventManager.RegisterClassHandler(
typeof(ListBoxItem),
DropEvent,
new RoutedEventHandler(OnListBoxItemDropEvent));

The following method signature is expected:

private void OnListBoxItemDropEvent(object sender, RoutedEventArgs e)

The standard Drop method signature is the following:

private void Drop(object sender, DragEventArgs e)

i.e. it gives you access to the DragEventArgs e

Is there a way for me to access the DragEventArgs e when registering a routed event handler?


Solution

  • How about creating a DragEventHandler (instead of a RoutedEventHandler)?:

    EventManager.RegisterClassHandler(
                    typeof(ListBoxItem),
                    DropEvent,
                    new DragEventHandler(Drop));