Skip to content

Override combobox enter key. #16088

Discussion options

You must be logged in to vote
public class MyComboBox:ComboBox
{
 
  protected override Type StyleKeyOverride => typeof(ComboBox); // for reuse the style

  protected override void OnKeyDown(KeyEventArgs e)
  {
      // Your logic
  }
}

Ref.

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Handled)
return;
if ((e.Key == Key.F4 && e.KeyModifiers.HasAllFlags(KeyModifiers.Alt) == false) ||
((e.Key == Key.Down || e.Key == Key.Up) && e.KeyModifiers.HasAllFlags(KeyModifiers.Alt)))
{
SetCurrentValue(IsDropDownOpenProperty, !IsDropDownOpen);
e.Handled = true;
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@maxkatz6
Comment options

@Quetzalcoatl2435
Comment options

Answer selected by Quetzalcoatl2435
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants