Modifying DragEventArgs.Data or DragEventArgs.DataView during DragEnter

Nathan Sokalski 4,121 Reputation points
2020-05-08T01:32:26.573+00:00

I have UWP app in which I want to allow the user to be able to drag an element, and when the element is dragged over another element (DragEnter), I want to change the target, and when they leave (DragExit), I want to change it back. To do this, I am storing the data about the item being dragged in args.Data.Properties during the DragStarting event. Then in the DragEnter event I use this data & attempt to temporarily store the data from the target element in e.DataView.Properties. However, this does not work because e.DataView.Properties is readonly. How can I modify the data in e.DataView.Properties during DragEnter & DragExit? Thanks.

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. John Torjo 861 Reputation points
    2020-05-08T06:58:56.167+00:00

    Here's my suggestion: on DragStarting, add a custom object to e.Data.Properties.

    Then, on DragEnter, get that object from e.DataView.Properties. Cast it to your object type. Then do whatever you want with it.


0 additional answers

Sort by: Most helpful