如何右对齐最后一个 TabControl 选项卡?
有没有办法使 TabControl 上的最后一个选项卡右对齐? 想让最后一个与前几个分开。
谢谢 !
Is there a way to make last tab on TabControl right-aligned ?
Want to make the last one separate from the first few.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这篇文章可能很旧,但我在寻找同一问题的答案时偶然发现了它,所以我想我会分享我最终得到的快速而肮脏的解决方案。
我只是将两个 TabControl 放在网格中,然后将其中一个 TabPanel 右对齐(感谢 Meleak):
然后,在 OnTabFocused 事件处理程序中,当用户单击 TabItem:
This post may be old, but i stumbled across it while searching for an answer to the same question, so i thought I'd share the quick and dirty solution I ended up with.
I just put two TabControls on top of each other in a Grid, and right-aligned the TabPanel on one of them (thanks go out to Meleak):
Then, in the OnTabFocused event handler, we need to bring the bottom-most TabControl to the front when the user clicks a TabItem:
这里是一个关于模板化 TabControl 选项卡的示例项目。我可能会使用具有三列宽度“自动”、* 和“自动”的网格,并在第一列中放置一个 StackPanel 来保存第一组选项卡,然后将最后一个选项卡单独放置在最后一列中,中间为中间的列列是空的,只占用剩余空间。
Here is an example project on templating the TabControl tabs. I would probably use a Grid with three columns of width "Auto", * and "Auto" and put a StackPanel in the first column to hold the first set of tabs and then just the last tab by itself in the last column with the middle column being empty and just taking up the remaining space.
如果您希望左侧有两个选项卡,右侧有一个选项卡,则可以在中间放置第三个不可见选项卡,并且不可见选项卡的
宽度
可以通过减去以下的宽度
来计算Window
的Actualwidth
中的所有三个可见选项卡为我们提供了剩余空间。这是示例代码
后端代码:
If you want to have two tabs at left and one at right, You can have the third invisible tab inbetween and
width
of the invisible tab can be calculated by subtracting theWidth
of all three visible tabs from theActualwidth
of theWindow
which gives us the remaining space.Here is the sample code
Backend Code: