1

How can I cause the tab item headers to stretch across the width of the tab control in Silverlight? If it matters, I have always a fix number of tabs.

I've found just WPF examples, with IMultiValueConverter here.

Community
  • 1
  • 1
Aaaaaaaa
  • 2,015
  • 3
  • 22
  • 40
  • Coding style means the style in which code is writen. It does nor affect the style of the UI. Please see [this clarification](http://en.wikipedia.org/wiki/Programming_style). – Apoorv May 25 '11 at 11:11

1 Answers1

2

Here an example

http://cid-a1de71e9f2ae2f82.office.live.com/self.aspx/.Public/ExtendedTabControl.zip

It's preaty simple task.. all you have to do is to create Copy of default template and replace System_Windows_Controls_Primitives:TabPanel x:Name="TabPanelTop" with te:StockPanel x:Name="TabPanelTop" which basicly override layout logic..

public class StockPanel: System.Windows.Controls.Primitives.TabPanel
{
    protected override Size MeasureOverride(Size availableSize)
    {
        var cc = Children.Count;

        foreach (var child in Children)
        {
            child.Measure(new Size(availableSize.Width / cc, availableSize.Height));
        }

        return base.MeasureOverride(availableSize);
    }

    protected override Size ArrangeOverride(Size finalSize)
    {
        var cc = Children.Count;
        var i = 0;

        foreach (var child in Children)
        {
            child.Arrange(new Rect((finalSize.Width / cc) * i, 0, finalSize.Width / cc, finalSize.Height));
            i++;
        }

        return new Size(finalSize.Width, finalSize.Height);
    }
}

PS: it's not perfect code sample, but i think it's enouth for you to understand how to extend TabControl

obenjiro
  • 3,665
  • 7
  • 44
  • 82