question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DragDrop with TextBox no longer sets data type to StringFormat

See original GitHub issue

The code from the .NET Framework WPF walkthrough about drag-drop, it doesn’t work on .NET 5/Core 3.1: https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-enabling-drag-and-drop-on-a-user-control?view=netframeworkdesktop-4.8

Specifically it’s this check:

if (e.Data.GetDataPresent(DataFormats.StringFormat))

In .NET Framework the drag-drop operation is initiated from a textbox creates a the data object of type DataFormats.StringFormat.

In .NET 5/Core 3.1, the data object generated is DataFormats.Text

Reported in dotnet/docs-desktop#160

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
adegeocommented, Jun 14, 2021

Tagging @einarstokke and @rubend30 for notifications

0reactions
miloushcommented, Sep 11, 2022

This is happening because of https://github.com/dotnet/wpf/commit/875b508196b1c69bf930ee676ee9aa5d594c32f7:

image

The last parameter, autoConvert is true by default on .NET Framework (except for DataFormats.ApplicationTrust):

https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Documents/TextEditorCopyPaste.cs,822

This almost looks like an oversight during the broad commit to me, since users can get SystemFormat from Clipboard.GetDataObject().GetFormats() after setting string even in .NET Core.

That said, the documentation could probably be changed to just use UnicodeText.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drag and drop for more the one text box
suppose I need to drag for more than 2 text box ,instead of copy the code can I write it in dynamic way...
Read more >
Drag-Drop to text box does not work [SOLVED] - vb.net
I had to set AllowDrop manually in the form load and add the handlers ... dragged a file to it; the data did...
Read more >
Walkthrough: Enabling Drag and Drop on a User Control
This walkthrough demonstrates how to create a custom user control that can participate in drag-and-drop data transfer in Windows Presentation ...
Read more >
Thread: Drag/Drop to ALL text boxes on form
Each section has text boxes, so how would I code it so they are all capable of allowing drag/drop without specifying each one...
Read more >
Textbox Drag/Drop in WPF
When you attempt to drag and drop an item into a TextBox , it refuses to cooperate and leaves the mouse cursor as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found