Sugrue
Sugrue

Reputation: 3739

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:

align wpf tabcontrol strip

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

At this point I am out of ideas.

Upvotes: 2

Views: 5999

Answers (3)

Edward Burley
Edward Burley

Reputation: 1

I ended up inserting a hidden tab between the tabs on the left and right to separate them. Simple, and almost does what I want, but the size isn't automatic.

<TabItem IsEnabled="False" Visibility="Hidden">
  <TabItem.Header>
      <Label Content=" " Width="200"/>
  </TabItem.Header>
</TabItem>

Upvotes: 0

Onfealive
Onfealive

Reputation: 70

Thank "Andrew Hanlon", you can use Blend to edit the TabControl template.

  • Replace TabPanel with DockPanel
  • Then add HorizontalAlignment="Right"

It works with me.

Upvotes: 0

Rachel
Rachel

Reputation: 132618

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.

Upvotes: 3

Related Questions