Skip to content

Optionally ignore the TabControl keybindings, which blocks some keybindings from inner elements.#508

Open
Rijno wants to merge 4 commits intoDirkster99:masterfrom
Rijno:master
Open

Optionally ignore the TabControl keybindings, which blocks some keybindings from inner elements.#508
Rijno wants to merge 4 commits intoDirkster99:masterfrom
Rijno:master

Conversation

@Rijno
Copy link

@Rijno Rijno commented Jul 9, 2025

WPF's TabControl aggressively captures keybindings, even if the focus is on inner elements within an AvalonDock DocumentPane.

This was an issue that popped up when I added a code editor as a Document within AvalonDock. Where I noticed the Home and End keys, were not captured by the code editor, but instead switched between the first and last TabControl items.

This can be bypassed by overriding the OnKeyDown event on an element that uses the TabControl and not calling the base.OnKeyDown function of the base TabControl.
This is well explained in this blogpost.

I could not find a way to do this without editing AvalonDock, as it must be set on one of the elements that are derived from TabControl.

I've added a property to ignore these key bindings (IgnoreTabControlKeyBindings), which is disabled by default, so not to affect any AvalonDock users. Personally, I wouldn't mind if this is always ignored, as I've never realized TabControl had these keybindings anyway, and I find its usefulness minimal at best.

It would be fantastic if this could be merged with the AvalonDock with any changes you deem necessary to fit into this codebase.
Thank you.

Example:
TabControl

@wookoon2024
Copy link

I'm having the same issue and was wondering how you fixed it.

@Rijno
Copy link
Author

Rijno commented Feb 17, 2026

I'm having the same issue and was wondering how you fixed it.

Simplified, I added the snippet below to TabControlEx to prevent TabControlEx of calling the base (WPF's TabControl) OnKeyDown from firing.
See this blogpost which explains it better than I can.

protected override void OnKeyDown(KeyEventArgs e)
{
	//Do NOT call `base.OnKeyDown(e);` to prevent the base TabControl HOME & END keybindings from firing.
}

In my pull-request I made it toggle-able with a dependency-property to keep the default functionality intact.

In the end I switched to our own branch of AvalonDock to have the fix applied as this one has not had an update in quite a while.

Hope this helps!
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants