I currently have this code:
DataGrid.SelectionChanged += new SelectionChangedEventHandler(DataGrid_SelectionChanged);
private void DataGrid_SelectionChanged(object sender, EventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
{
//do stuff
}
}
The code checks for the Ctrl button when the selection in a data grid changes which works fine for detecting the Ctrl key for normal physical keys but when I use the on screen keyboard and press down the Ctrl key it doesn't register in my program. The root of this code is that you cannot Ctrl+Click the rows in a Datagrid in WPF when you use the Ctrl key of the on screen keyboard.
Edit: It seems to satisfy the if condition if, on the on screen keyboard, I press ctrl and then "A" (which selects all). None of the other shortcuts (ctrl+c, ctrl + v trigger this response)