I'm trying to develop a wpf app with a datagrid, and i want to allow the users to enter values like in excel.
Example: The datagrid has 2 columns, Name and BarCode The user is editing the BarCode on the first row, and when the user press Enter key, the focus should move the the row below on the BarCode cell.
The user must be able to use a barcode scanner to register the barcodes, on the existing products list, without need to user the mouse or the keyboard.
Any ideas on how to implement this behavior?
Thanks, Frederico
A simpler solution is capture the KeyDown event and if the key is 'Enter', then move to the next tab.
private void dg_PreviewKeyDown(object sender, KeyEventArgs e)
{
var u = e.OriginalSource as UIElement;
if (e.Key == Key.Enter && u != null)
{
e.Handled = true;
u.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With