是否可以创建一个看起来与选项卡控件完全不同的 WPF 选项卡控件模板?

发布于 2024-08-03 19:06:17 字数 90 浏览 3 评论 0原文

我想要的是一个功能类似于选项卡控件的控件,但不是将选项卡放在顶部,而是将项目显示在侧面的列表框中。我想这是可能的,但还没有找到任何例子,我希望这里有人做过这样的事情。

What I'd like is a control that functions just like the tab control but instead of having the tabs along the top, the items would be displayed in a list box along the side. I imagine it's possible but haven't found any examples, I'm hoping there's someone here that's done something like this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等往事风中吹 2024-08-10 19:06:17

WPF 控件旨在实现您想要的功能。重用控制功能,同时完全取代视觉表示。您必须为 TabControl 创建自己的 ControlTemplate。您可以在 MSDN 上找到 TabControl ControlTemplate 示例。您还必须学习MSDN 上的控件创作概述

实际上,我发现 Silverlight 3 文档更容易理解,尽管在控制样式方面存在一些差异,但基本概念仍然是相同的。您可以阅读使用 ControlTemplate 自定义现有控件的外观在 MSDN 上了解控件模板,然后研究 TabControl 样式和模板了解在 Silverlight 中创建您自己的控件模板所需的内容。

您可以使用 Expression Blend 提取 WPF 中的默认 TabControl 模板。

WPF controls are designed to enable exactly what you want. To reuse control functionality while completely replacing the visual representation. You will have to create your own ControlTemplate for the TabControl. You can find a TabControl ControlTemplate Example on MSDN. You will also have to study the Control Authoring Overview on MSDN.

I actually find the Silverlight 3 documentation somewhat easier to digest, and even though there are some differences when it comes to control styling the fundamental concepts are still the same. You can read Customizing the Appearance of an Existing Control by Using a ControlTemplate on MSDN to learn about control templates and then study TabControl Styles and Templates to discover what is required to create you own control template in Silverlight.

You can use Expression Blend to extract the the default TabControl template in WPF.

相守太难 2024-08-10 19:06:17

您根本不需要使用 TabControl。您可以将 ListBox 绑定到项目列表,然后在其旁边放置一个 ContentControl ,绑定到所选项目:

<DockPanel>
    <ListBox Name="listBox"
             DockPanel.Dock="Left"
             ItemsSource="{Binding Items}"
             DisplayMemberPath="Name"/>
    <ContentControl Content="{Binding SelectedItem, ElementName=listBox}"
                    ContentTemplate="{StaticResource theTemplate}"/>
</DockPanel>

You don't need to use a TabControl at all. You could just bind your ListBox to a list of items, and put a ContentControl beside it, bound to the selected item :

<DockPanel>
    <ListBox Name="listBox"
             DockPanel.Dock="Left"
             ItemsSource="{Binding Items}"
             DisplayMemberPath="Name"/>
    <ContentControl Content="{Binding SelectedItem, ElementName=listBox}"
                    ContentTemplate="{StaticResource theTemplate}"/>
</DockPanel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文