标签控件宽度wpf
我有一个带有 n 个选项卡的 TabControl。 我试图限制 TabControl 的宽度,以便如果我只剩下一个选项卡,那么当我调整包含 Tabcontrol 的主窗口的大小时,它的标题将始终可见。 有什么建议吗?
I have a TabControl with n tabs.
I am trying to limit the TabControl's width so that if I have only one Tab left, then its header would be always visible when I resize the main window that contains the Tabcontrol.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通常会在只剩下一项时隐藏该选项卡:
如果您想显示某些内容,您可以将其堆叠在上面并仅在计数降至 1 时才显示它。
编辑: 我可能应该提到你的问题实际上没有太大意义,你应该尝试更清楚地表达自己。关于您可能的意思的一种猜测是您希望最后一个剩余的选项卡拉伸整个可用宽度。这并不是那么简单,因为标题位于 TabPanel 中,不能简单地拉伸它。
一种近似方法是绑定到 TabControl 的宽度:
但这有点太大,您可能需要使用 ValueConverter。
编辑2:像这样:
I would normally hide the tab when only one item is left:
If you want to display something instead you could stack it above and show it only when the count drops to 1.
Edit: I probably should have mentioned that your question does in fact not make all too much sense, you should try to express yourself more clearly. One guess as to what you might have meant is that you want the last remaining tab to stretch the whole available width. This is not that simple because the header is in a TabPanel, it cannot simply be stretched.
One approximation would be to bind to the TabControl's width:
But this is a bit too large, you might want to subtract a small value by using a ValueConverter.
Edit2: Like this: