如何在 WPF 中将一个 TabControl 绑定到另一个 TabControl 的 TabItem?
我定义了以下名为 TabControl1 的 TabControl:
<TabControl>
<TabItem Header="Cheese"> The Cheese Tab </TabItem>
<TabItem Header="Pepperoni"> The Pepperoni Tab </TabItem>
<TabItem Header="Mushrooms"> The Mushrooms Tab </TabItem>
</TabControl>
我定义了另一个 TabControl TabControl2,它是从加载项或插件动态加载的:
<TabControl>
<TabItem Header="Anchovies"> The AnchoviesTab </TabItem>
<TabItem Header="Jalepenos"> The Jalepenos Tab </TabItem>
<TabItem Header="Rattle Snake"> The Rattle Snake Tab </TabItem>
</TabControl>
TabControl1 在“Cheese”项之后绑定到 TabControl2 后,TabControl1 应如下所示:
<TabControl>
<TabItem Header="Cheese"> The Cheese Tab </TabItem>
<TabItem Header="Anchovies"> The AnchoviesTab </TabItem>
<TabItem Header="Jalepenos"> The Jalepenos Tab </TabItem>
<TabItem Header="Rattle Snake"> The Rattle Snake Tab </TabItem>
<TabItem Header="Pepperoni"> The Pepperoni Tab </TabItem>
<TabItem Header="Mushrooms"> The Mushrooms Tab </TabItem>
</TabControl>
I've defined the following TabControl called TabControl1:
<TabControl>
<TabItem Header="Cheese"> The Cheese Tab </TabItem>
<TabItem Header="Pepperoni"> The Pepperoni Tab </TabItem>
<TabItem Header="Mushrooms"> The Mushrooms Tab </TabItem>
</TabControl>
I've defined another TabControl, TabControl2 which is dynamically loaded from an add-in or plugin:
<TabControl>
<TabItem Header="Anchovies"> The AnchoviesTab </TabItem>
<TabItem Header="Jalepenos"> The Jalepenos Tab </TabItem>
<TabItem Header="Rattle Snake"> The Rattle Snake Tab </TabItem>
</TabControl>
After TabControl1 binds to TabControl2 after the "Cheese" item, TabControl1 should look like this:
<TabControl>
<TabItem Header="Cheese"> The Cheese Tab </TabItem>
<TabItem Header="Anchovies"> The AnchoviesTab </TabItem>
<TabItem Header="Jalepenos"> The Jalepenos Tab </TabItem>
<TabItem Header="Rattle Snake"> The Rattle Snake Tab </TabItem>
<TabItem Header="Pepperoni"> The Pepperoni Tab </TabItem>
<TabItem Header="Mushrooms"> The Mushrooms Tab </TabItem>
</TabControl>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用数据来建模您的 UI。即查看模型。从这些视图模型生成 UI:
然后,您可以根据需要将这些模型组合到集合中,并从这些集合生成 UI。
Use data to model your UI. i.e. view models. Generate the UI from those view models:
Then you can combine these models into collections as you see fit, and generate the UI from those collections.