Justin
Justin

Reputation: 2479

WPF- Is there a way to make a TabContol ignore CTRL-Tab and still fire CTRL-TAB keybindings on the parent window?

I have a TabControl in the mainwindow of my app. I also Have a keyBinding for CTRL-TAB. However, whenever the TabControl is selected and CTRL-TAB is pressed the keybinding is not triggered because the TabControl handles the input and cycles through the tabs.

Is there any way that I can fix this?

Upvotes: 1

Views: 238

Answers (1)

Ray Burns
Ray Burns

Reputation: 62939

Probably the easiest way to do this is to subclass TabControl and override the OnKeyDown method:

public class TabControlIgnoresCtrlTab : TabControl
{
  protected override void OnKeyDown(KeyEventArgs e)
  {
    if(e.Key == Key.Tab) return;
    base.OnKeyDown(e);
  }
}

Upvotes: 2

Related Questions