Adjusting TabItem width automatically to fill spaces?

user191720 picture user191720 · Oct 17, 2009 · Viewed 10.8k times · Source

I have a TabControl object with some TabItem objects inside. Now the sum of width of TabItem is not long enough to fill the space on right:

Now I wish to have one of following design:

alt text http://img111.imageshack.us/img111/4158/67279984.png

What properties should I set to archieve one of the design above? For the second design, I tried to adjust HorizontalAlignment property (to "center") in TabItem objects and HorizontalContentAglinment property (to "center") in TabControl object, but neither works.

Could someone point out what should I do to implement the design? I prefer the first design, but if it is impossible or very difficult, the second one would be nice too.

Thanks.

Answer

hwiechers picture hwiechers · Oct 18, 2009

The tabs are arranged by the TabControl's HeaderPanel. You need to replace the HeaderPanel to change the layout. It seems like the only way to do this is with a ControlTemplate. Here is an article that will show you how to do that: http://www.codeproject.com/KB/WPF/WpfSqueezeTabPanel.aspx.