Hello,
I want to override some functionality of the GridView combobox, datepicker and data column.
I overriden the class GridViewComboBoxColumn, but the functionality is not working.
My goal is for the combobox, when it receives focus it should show the dropdown, the user can then select the value with one enter and control should automatically move to the next field in the GridView.
The same functionality I want to implement for the DatePicker. And for the Textbox I want the enter function like the tab.
public class CustomGridViewComboBoxColumn : GridViewComboBoxColumn{ #region Fields private bool _isEnterInThisCombo = false; #endregion #region Constructor #endregion #region Methods private void ComboBox_PreviewKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && _isEnterInThisCombo) { if(this.IsVmEditMode && ! Validation.GetHasError(this)) { CbIsCheckedForAudit = true; } this.MoveFocus(new TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next)); /* Reset flag */ _isEnterInThisCombo = false; } } private void ComboBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { _isEnterInThisCombo = true; } } private void ComboBox_Loaded(object sender, RoutedEventArgs e) { if (this.IsVmEditMode) // && this.SelectedValue == null) this.CbOpenDropDownOnFocus = true; else if (this.IsVmEditMode) this.CbOpenDropDownOnFocus = false; else this.CbOpenDropDownOnFocus = true; } #endregion #region Dependency Properties public bool CbOpenDropDownOnFocus { get { return (bool)GetValue(CbOpenDropDownOnFocusProperty); } set { SetValue(CbOpenDropDownOnFocusProperty, value);} } public static readonly DependencyProperty CbOpenDropDownOnFocusProperty = DependencyProperty.Register("CbOpenDropDownOnFocus", typeof(bool), typeof(CustomGridViewComboBoxColumn), new PropertyMetadata(false)); public bool CbIsCheckedForAudit { get { return (bool)GetValue(CbIsCheckedForAuditProperty); } set { SetValue(CbIsCheckedForAuditProperty, value); } } public static readonly DependencyProperty CbIsCheckedForAuditProperty = DependencyProperty.Register("CbIsCheckedForAudit", typeof(bool), typeof(CustomGridViewComboBoxColumn), new PropertyMetadata(false)); public virtual bool IsVmEditMode { get { return (bool)GetValue(IsVmEditModeProperty); } set { SetValue(IsVmEditModeProperty, value); } } public static readonly DependencyProperty IsVmEditModeProperty = DependencyProperty.Register("IsVmEditMode", typeof(bool), typeof(CustomGridViewComboBoxColumn), new PropertyMetadata(false)); #endregion
Thanks in advance.
Marcel