Hello Devz,

Manipulating the clipboard content is pretty easy. But it can become handy when pasting it in a GridView. Here a simple example on how to paste the content of the clipboard from Excel to a GridView.

First things first! Here is how to use the clipboard:

Obviously you could use the SetText(string) method as well, but it’s not the purpose in our tutorial.

What we want is to copy the content of an Excel sheet and get it in our GridView.

Excel content to paste to our GridView

Excel content to paste to our GridView

Ok, now let’s create our WPF application, starting with the Model:

Here is our GridView:

As you can see, we added a KeyBinding to bind the CTRL+V event to a PasteCommand.

And now our ViewModel:

So when you copy the content of the Excel file, rows are separated by “\r\n” and columns by “\t”.

And here is the result:

wpf copy paste from Excel to GridView result

wpf copy paste from Excel to GridView result

Happy pasting!  🙂