Search code examples
wpfwpf-controlstabcontroltabitem

How to have some tabs aligned left and others aligned right? (TabControl in wpf)


I have a tabcontrol and I want to put some tabitem headers aligned to the left, and others aligned to the right. Like in this mock screenshot:

http://img269.imageshack.us/img269/8894/tabcontrol.png

What I've tried already:

  • Styles: I can right align the tabitem using this:

align wpf tabcontrol strip

But I haven't been able to find a way to mix left and right aligned tab items.

  • Using two TabControls: I can have two overlapping TabControls, one with left aligned tabs, the other with Right aligned tabs. The difficulty is getting them to switch. Click or MouseDown don't fire consistently when the user clicks the tab header (even with Ishitvisible = true). SelectionChanged doesn't work because if the user has previously selected tab 'D' in TabControl 2, then goes to Tab 'A' and back to 'D' - TabControl 2 doesn't know the selection has changed.

At this point I am out of ideas.


Solution

  • You could try overwriting the Template for the TabPanel, however if that doesn't work you'll have to overwrite the TabControl.Template. Default control templates can be found here

    Edit

    Just tested, and TabPanel doesn't have a template you can override, so your best bet would be to overwrite the TabControl.Template to use your own Panel for hosting TabItems.