自动调整TabItem宽度以填充空格?
我有一个 TabControl 对象,里面有一些 TabItem 对象。现在 TabItem 的宽度总和不够长,不足以填充右侧的空间:
现在我希望有以下设计之一:
alt text http://img111.imageshack.us/img111/4158/67279984.png
我应该设置哪些属性来实现上述设计之一?对于第二种设计,我尝试调整 TabItem 对象中的 HorizontalAlignment 属性(至“center”)和 TabControl 对象中的 HorizontalContentAglinment 属性(至“center”),但两者都不起作用。
有人可以指出我应该做什么来实现设计吗?我更喜欢第一个设计,但如果不可能或非常困难,第二个也不错。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选项卡由 TabControl 的 HeaderPanel 排列。您需要替换 HeaderPanel 来更改布局。似乎执行此操作的唯一方法是使用 ControlTemplate。这里有一篇文章将向您展示如何做到这一点:
http://www.codeproject.com/KB/WPF/WpfSqueezeTabPanel.aspx。
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.
请参阅我对这个类似问题的回答(如果我理解正确的话):
如何拉伸 WPF 选项卡项标题到父控件宽度
Please see my answer on this similar question(If I understood correctly):
How to Stretch WPF Tab Item Headers to Parent Control Width