DragDrop with TextBox no longer sets data type to StringFormat
See original GitHub issueThe 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:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Tagging @einarstokke and @rubend30 for notifications
This is happening because of https://github.com/dotnet/wpf/commit/875b508196b1c69bf930ee676ee9aa5d594c32f7:
The last parameter,
autoConvert
istrue
by default on .NET Framework (except forDataFormats.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
fromClipboard.GetDataObject().GetFormats()
after setting string even in .NET Core.That said, the documentation could probably be changed to just use
UnicodeText
.