Good day,
We have a GridView and would like to do enter key traversing instead of doing Tab key traversing, when editing a row.
Note that we are using MVVM type architecture.
For a normal grid, the following works fine, but does not seem to work on the telerik RadGridView:
Any help would be much appreciated.
Kind regards
We have a GridView and would like to do enter key traversing instead of doing Tab key traversing, when editing a row.
Note that we are using MVVM type architecture.
For a normal grid, the following works fine, but does not seem to work on the telerik RadGridView:
public class EnterKeyTraversal{ public static bool GetIsEnabled(DependencyObject obj) { return (bool)obj.GetValue(IsEnabledProperty); } public static void SetIsEnabled(DependencyObject obj, bool value) { obj.SetValue(IsEnabledProperty, value); } static void ue_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { var ue = e.OriginalSource as FrameworkElement; if (ue != null && (e.Key == Key.Enter && ue.GetType() != typeof(Button))) { e.Handled = true; ue.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); } } private static void ue_Unloaded(object sender, RoutedEventArgs e) { var ue = sender as FrameworkElement; if (ue == null) return; ue.Unloaded -= ue_Unloaded; ue.PreviewKeyDown -= ue_PreviewKeyDown; } public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(EnterKeyTraversal), new UIPropertyMetadata(false, IsEnabledChanged)); static void IsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var ue = d as FrameworkElement; if (ue == null) return; if ((bool)e.NewValue) { ue.Unloaded += ue_Unloaded; ue.PreviewKeyDown += ue_PreviewKeyDown; } else { ue.PreviewKeyDown -= ue_PreviewKeyDown; } }}
Any help would be much appreciated.
Kind regards