WPF BindableMultiSelectDataGrid Clipboard Copy Error

O'Rourke, Ian 25 Reputation points
2026-04-13T16:31:11.81+00:00

When copying from a BindableMultiSelectDataGrid with WPF in .NET 10, copying to the clipboard seems to be erroneous in a way that is incompatible with Excel.

In .NET 10, it seems that an extra newline is placed between each line of the HTML clipboard format. When copying directly from the data grid view to Excel, this causes problems. Instead, if I add a function after copying to the clipboard to take the same text and remove the empty extra newline values, copying into Excel works correctly.

This used to work correctly with .NET 8, but appears to have been modified with .NET 10.

For example, from .NET 10, the HTML copied to the clipboard looks like the following:

Version:1.0

StartHTML:00000097

EndHTML:00000366

StartFragment:00000133

EndFragment:00000330

<HTML>

<BODY>

<!--StartFragment--><TABLE><TR><TD>0.154475</TD><TD>0.142117</TD><TD>0.126669</TD></TR><TR><TD>0.154475</TD><TD>0.142117</TD><TD>0.111222</TD></TR><TR><TD>0.134393</TD><TD>0.142117</TD><TD>0.111222</TD></TR></TABLE>

<!--EndFragment-->

</BODY>

</HTML>

Whereas for .NET 8, the same application provides the following. The content is identical, except for the duplicate newline values.

Version:1.0
StartHTML:00000097
EndHTML:00000366
StartFragment:00000133
EndFragment:00000330
<HTML>
<BODY>
<!--StartFragment--><TABLE><TR><TD>0.154475</TD><TD>0.142117</TD><TD>0.126669</TD></TR><TR><TD>0.154475</TD><TD>0.142117</TD><TD>0.111222</TD></TR><TR><TD>0.134393</TD><TD>0.142117</TD><TD>0.111222</TD></TR></TABLE>
<!--EndFragment-->
</BODY>
</HTML>

Developer technologies | Windows Presentation Foundation
0 comments No comments

Answer accepted by question author

Jack Dang (WICLOUD CORPORATION) 18,975 Reputation points Microsoft External Staff Moderator
2026-04-14T06:57:03.5233333+00:00

Hi @O'Rourke, Ian ,

Thanks for reaching out.

The more robust approach is to take control of the clipboard serialization rather than trying to adjust the framework-generated output after the fact. In practice, that usually means building your own CF_HTML payload so that both the HTML fragment and all offset values remain consistent.

If you want to stay closer to the WPF pipeline, you can use events such as CopyingRowClipboardContent to inspect or shape the data being copied, but it is best treated as a hook for gathering or transforming the content before your own clipboard serialization step, rather than something that directly controls the final CF_HTML packaging.

WPF does not appear to expose a setting to control how CF_HTML is emitted, so if this difference is affecting Excel interoperability, it would be reasonable to raise it as a potential regression for the product team to review.

Hope this helps! If my explanation and the information I provided were useful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.

Was this answer helpful?

2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.