开发者

Strech TabItem header in Silverlight

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜