TabControl 的自定义 ControlTemplate
目前,在我的一个视图中,我有以下 TabControl 设置:
<TabControl ItemsSource="{Binding Workspaces}"
ItemTemplate="{StaticResource WorkspaceTemplate}"
IsSynchronizedWithCurrentItem="True" Background="{x:Null}">
我想通过设置 ControlTemplate 属性来完全更改 TabControl 的外观和感觉。我的计划是不让任何其他选项卡可见,只让当前选项卡的内容可见,在任何地方都看不到 TabControl,但仍然允许用户通过 Ctrl+Tab 切换到其他选项卡。
坦白说,我不知道从哪里开始。我尝试将 ContentPresenter 添加到 TabControl 的 ControlTemplate,但我不知道如何将其绑定到当前活动的选项卡(注意,不是实际的选项卡,而是 TabItem 的内容)。
有什么帮助或者一些样板代码可以帮助我开始吗?也许有一个更合适的控件(即使这意味着我将不得不失去 Ctrl+Tab 功能)。
Currently, in my one of my Views, I have the following TabControl setup:
<TabControl ItemsSource="{Binding Workspaces}"
ItemTemplate="{StaticResource WorkspaceTemplate}"
IsSynchronizedWithCurrentItem="True" Background="{x:Null}">
I would like to change the look and feel of the TabControl completely by setting up the ControlTemplate property. My plan is to have none of the other tabs visible and only have the contents of the current tab visible with no trace of the TabControl anywhere but still allowing user to Ctrl+Tab to other tabs.
Frankly speaking, I have no idea where to start. I tried adding a ContentPresenter to the TabControl's ControlTemplate but I can't figure out how to bind it to the currently active tab (note, not the actual tab but the TabItem's contents).
Any help or perhaps some boilerplate code to get me started? Perhaps there's a more suitable control out there (even if it means I'll have to lose the Ctrl+Tab functionality).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建自己的 ControlTemplate。
You can just create your own ControlTemplate.