选项卡标题旁边的 UIElements
有没有办法将某些内容(自定义 UIElement
)放置在 TabItem
标题的右侧,以便标题会考虑其大小。
我觉得应该有一个适合他们的数据模板,但我不知道该读什么或如何查询谷歌。
Is there a way to place something (a custom UIElement
) in place on the right of TabItem
s' headers, so that the headers will consider its size.
I feel like there should be a data template for them, but I do not know what to read or how to query google for that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有一种简单的方法可以将内容放置在该位置,但有一种方法。 为此,您必须覆盖
TabControl
的默认ControlTemplate
。大多数系统主题将
TabPanel
(选项卡所在的位置)和选项卡内容放在Grid
中,如下所示:因此您可以添加另一个 ContentControl网格并将其绑定到自定义附加属性。 请记住,默认的 ControlTemplates 还具有许多控制溢出处理的触发器等,并且您必须确保其他 UI 元素不会干扰这些触发器。
不过,如果您不必处理 TabControl 方向或溢出,您应该能够很快获得类似的结果:
三个带有红色边框和 TextBlock 的 TabItem http://img35.imageshack.us/img35/3237/tabpanelexample.png
祝你好运!
There isn't an easy way to place content in that location, but there is a way. To do that you'll have to override the default
ControlTemplate
forTabControl
.Most system themes put the
TabPanel
(where the tabs are) and the tab contents in aGrid
like so:So you could add another ContentControl to the grid and have it bind to a custom Attached Property. Keep in mind that the default ControlTemplates also have a lot of triggers which control overflow handling, amongst other things, and you'd have to make sure that your additional UI Elements don't interfere with that.
You should be able to get something like this fairly quickly, though, if you don't have to deal with TabControl orientation or overflow:
Three TabItems with a Red Border and TextBlock http://img35.imageshack.us/img35/3237/tabpanelexample.png
Good luck!