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)
I ended up coding around the problem and added a check box to every row in the datagrid. Although this no longer allows for the use of ctrl+click and shift+click the selection mechanics works just as well as it does on a touch screen as it does on a physical keyboard. I hope eventually the on screen keyboard will be more full featured and have less "bugs".