I am using data grid in wpf, and it has copy and paste by default.
I have a date time column and i used binding and String format to make it show it in the date time format i want.
However, when i copy and paste, the pasted text becomes the unformatted date time.
Is there a way to do a copy a paste on "What you see is what you get?"
Thanks, Kev
Edit: I tried using ClipboardContentBinding, putting same thing as i did in binding. And that didn't work
DataGrid has a number of clipboard extensibility points you can hook into and see what is going on. The grid itself has a CopyingRowClipboardContent event that apart from having all the needed information in the event arguments has a nice helper method FormatClipboardCellValues(string format). Also each column has a CopyingCellClipboardContent which can be used for your particular data time column needs.
Note: By default DataGrid's bound columns (those deriving from DataGridBoundColumn) will have them ClipboardContentBinding pointing to the Binding property if not specified explicitly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With