I've got a Virtual Grid with 29 rows of data and 3 columns. I want to have a function that copies all of its contents to the clipboard. My handler looks like this:
private void RadMenuItem_OnClick(object sender, RadRoutedEventArgs e)
{
// Select all cells and then copy them to the clipboard
VirtualGrid.SelectAll();
VirtualGrid.CopyToClipboard();
}
I wrote my event handler for the CopyingCellClipboardContent event to use the cell row and column index to return the data item for whatever cell was requested:
private void VirtualGrid_OnCopyingCellClipboardContent(object? sender, VirtualGridCellClipboardEventArgs e)
{
if (TryGetCellString(e.Cell.RowIndex, e.Cell.ColumnIndex, out var s))
e.Value = s;
Debug.WriteLine($"Copying cell {e.Cell.RowIndex}, {e.Cell.ColumnIndex} => \'{e.Value}\'");
}
And sure enough, my handler was called 87 times (29 rows x 3 columns). But every single time it was called, the row and column index was exactly the same -- whatever row and column I had last clicked. here is some of my debug output
SelectedSellsChanged Copying Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000' Copying cell 1, 0 => '575.500, 1.000'
I can visually see the SelectAll() call selecting all the cells. And my selection mode is Extended. And it calls my handler the correct number of times.
So why does it keep asking me for exactly the same cell all 87 times? Shouldn't those row/column indices be changing?