Thursday, September 4, 2008

Copy data from a select in a WPF Listview

Simple little thing that was useful, i needed to copy the data from a row in a listview to the clipboard. all i needed to do was add the following to my listview:

<ListView.CommandBindings>
<CommandBinding Command="Copy" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed"/>
</ListView.CommandBindings>

and then create the methods for the CanExecute and Executed in the code-behind. For my CanExecute, i just checked if a row was selected, and for the Executed, i took the selected row, and casted it as the object that i expected, and put the data i wanted from the object in the clipboard

Clipboard.SetText(thePrj.ProjectGUID.ToString)

Very easy!

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home