[Original] analysis on the function of separately copying cells after binding data to the Silverlight control DataGrid, silverlight Control
A few days ago, the company's new requirements needed to replicate any cell data in the silverlight datagrid. After reading the network information for half a day, the staff did not find the relevant information, at first, I thought that the root of the silverlight bug could not be implemented,
Finally, it is implemented. This event has not been recorded on MSDN. The specific code is as follows:
The previous xaml file requires a datagrid to bind a replication event:
CopyingRowClipboardContent = "maid"
The background code is implemented as follows:
Void dataGrid_CopyingRowClipboardContent (object sender, DataGridRowClipboardEventArgs e) {var temp = e. clipboardRowContent; var dgData = sender as DataGrid; Int32 I = dgData. currentColumn. displayIndex; string sColumnValue = (TextBlock) this. dataGrid. columns [I]. getCellContent (this. dataGrid. selectedItem )). text. trim (); temp. clear (); temp. insert (0, new maid (e. item, dgData. currentColumn, sColumnValue ));}
In this way, you can copy cells (that is, copy the cell value where the current mouse clicks the row). Otherwise, the default value is to copy all column data in a row.