DataGrid: apply binding StringFormat when copying to the clipboard
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
Currently, if you define a StringFormat value in a binding for a column, it faithfully reproduces the format for the displayed value, but ignores the format when copying to the clipboard.
Simple example:
```xml
```
A value of `.1234` will display as `12.34%` but copy as `.1234`.
This also applies when using a ClipboardContentBinding:
```xml
```
Here, a value of `2.50` will display as `$2.50` and copy as `2.50` rather than `$2.5000` as one might expect.
Passing a pre-formatted string to the column fixes the clipboard behavior, but it can come at the cost of proper sorting (e.g., date values and most non-ISO-8601 date formats).
To properly format the clipboard value without this trade-off involves passing a pre-formatted or value-converted value to ClipboardContentBinding, e.g.:
```xml
```
_minimal example project attached_
[testclipboardformatting.zip](https://github.com/dotnet/wpf/files/7227395/testclipboardformatting.zip)
---
A much preferable behavior would be to utilize the StringFormat from the ClipboardContentBinding (or Binding) automatically so such work-arounds aren't required.
Contributor guide
Assessment
This issue has not been assessed yet.