question

JoergReichert-8712 avatar image
0 Votes"
JoergReichert-8712 asked HuiLiu-MSFT edited

WPF TextBox: Cancelling drop operation leaves insertion marker as graphical glitch

I have a WPF App in that I want to cancel a drop operation to a TextBox, if some conditions are met (see shouldCancelDrop below):

Sample:

XAML:

    <TextBox PreviewDrop="TextBox_PreviewDrop" />


Code behind:

 private void TextBox_PreviewDrop(object sender, DragEventArgs e)
 {
     //Decision if to cancel to drop
     var shouldCancelDrop = false;
     //if (...) shouldCancelDrop = true;
        
     if (shouldCancelDrop)
     {
         e.Handled = true;
         return;
     }
    
     //...
 }

Problem is: After leaving the TextBox_PreviewDrop-Handler with e.Handled = true the "insertion marker" is always left in the textbox. It looks like a textcursor but is light gray and not blinking, see here (the right black one is the textcursor):

Insertion marker.

How can I get rid of this Insertion marker when I cancel the drop?

It stays in the TextBox until I finish another drag operation!

So I am looking for some "CancelDropOperationAndRedrawTextBox"-Action...


windows-wpf
image.png (6.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@JoergReichert-8712. After my test, I did not reproduce your problem. Could you show me the complete code to reproduce it?

0 Votes 0 ·

0 Answers