WinUI3: Can we get Drop event on a textblock by dragging a textblock on it?

Harshithraj1871 1,516 Reputation points


I'm trying to achieve Drag and drop for my grid. Each cell in the grid is a TextBlock
I wanted to get an experience like Dragging a textblock on another and them exchanging their places. So I stared with basic steps.
Here is My XAML code
I was able to drag a textbox, but I have the following queries

  1. What does the stop symbol[Which came when dragging in the above example]mean? Does it mean that the target area is not a valid Drop Target?
  2. While I did drag on the Debit textblock to the credit textblock, I was able to capture events like DragEntered, and DragOver in the credit textblock, but I was unable to Capture a drop event, How do capture a textblock drop on another TextBlock?Is it possible to do so?

I'm trying to achieve this in C++, was not able to find a good drag-and-drop example in C++, It would be of great help if you could help me with this.

Thank you

Universal Windows Platform (UWP)
Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
737 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,595 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 82,326 Reputation points

    (I tested in C# because it takes hours to compile C++/WinRT on my OS..)

    In DragOver event of the destination TextBlock, I set e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
    Then I receive Drop event on the destination TextBlock (with "Unknown" text in my test) :


    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful