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))
{
}
}
The code checks the Ctrl button when the selection in the data grid changes, which works fine for detecting the Ctrl key for regular physical keys, but when I use the on-screen keyboard and press the Ctrl key, it does not register in my program. The root of this code is that you cannot Ctrl + click rows in a Datagrid in WPF when you use the Ctrl key on the on-screen keyboard.
Edit: It seems to satisfy the if condition if I press ctrl on the on-screen keyboard and then βAβ (which selects everything). None of the other shortcuts (ctrl + c, ctrl + v does not trigger this answer)
user1184321
source
share