简体   繁体   English

WPF TabItem样式-更改标题文本后重新绘制选项卡

[英]WPF TabItem Style - Redraw tab after changing header text

I have used the excellent post How to create trapezoid tabs in WPF tab control in order to make my own TabControl. 我使用了出色的文章“ 如何在WPF选项卡控件创建梯形选项卡”以制作自己的TabControl。

I'm trying to figure how to change the tab width calculation after changing the header text?? 我试图弄清楚在更改标题文本后如何更改制表符宽度计算? I begin with a header text of "New Group", after the user enter text in some TextBox I want that text to appear in the Header, but now the TabItem width is not right for the new text. 我从“ New Group”的标题文本开始,在用户在某个TextBox中输入文本之后,我希望该文本出现在Header中,但是现在TabItem宽度不适用于新文本。

How to recalculate the width ??? 如何重新计算宽度???

Thank you 谢谢

try to use this style . 尝试使用这种样式 It recalculates the header width to fit the name. 它重新计算标题宽度以适合名称。

Well, I didn't find any solution so I did it quite dirty. 好吧,我没有找到任何解决方案,所以我做的很脏。 I just did that 我就是那样

TabItem.Style = null;
TabItem .Style = (Style)FindResource("Tabitem112");

So basically, I just dropped the style and re-applied it. 因此,基本上,我只是放弃了样式并重新应用了它。 It's working. 工作正常 I'd like to see a more professional approach. 我希望看到一种更专业的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM