How do I trigger an event from pasting in DataGrid?
I am trying to take the text from clipboard, split it into an array and create a new row in the datagrid for each element in the array. However, I am having difficulty getting the method to trigger. Like so:
void delivGrid_Keydown(object sender, KeyEventArgs e)
{
if (e.Key == Key.V &&
(Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
string clipData = System.Windows.Clipboard.GetText();
string[] clipRows = Regex.Split(clipData, @"\r");
foreach (var row in clipRows)
{
delivGrid.Items.Add(new Deliverable { name = String.Empty, desc = row, rDays = String.Empty });
}
//viewModel.Paste()
}
}
I haven't been able to find anything on a paste event for a WPF Datagrid. Does anybody know of a way that I could trigger this event for to intercept the pasting?