Silverlight 中的拉伸 TabItem 标头

发布于 2024-11-09 18:33:24 字数 230 浏览 1 评论 0原文

如何使选项卡项标题在 Silverlight 中拉伸到选项卡控件的宽度?如果重要的话,我总是有固定数量的选项卡。

我只找到了 WPF 示例,使用 IMultiValueConverter 在这里

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫罗兰の梦幻 2024-11-16 18:33:24

这是一个示例

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

这是非常简单的任务..您所要做的就是创建默认模板的副本并替换 System_Windows_Controls_Primitives:TabPanel x:Name="TabPanelTop"te:StockPanel x:Name="TabPanelTop" 基本上覆盖了布局逻辑。

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:这不是完美的代码示例,但我认为这足以让您理解如何扩展 TabControl

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文