WPF中的TabControl/TabItems [英] TabControl/TabItems in WPF

查看:89
本文介绍了WPF中的TabControl/TabItems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序(C#),其中有以下内容:
多个选项卡控件,每个控件具有多个选项卡项.我试图在选项卡控件之间切换时选择相同的选项卡项.所有选项卡都是动态创建的.

例如:如果tabControl1选中了tabItem3,则当您选择tabControl2时,将选中tabItem3.

谢谢.

I have an WPF application (C#) where I have the following:
Multiple tab controls and each control have multiple tab items. I am trying to have the same tab item selected when switching between tab controls. all tabs are created dynamically.

Ex: if tabControl1 has tabItem3 selected then when you select tabControl2, tabItem3 is selected.

Thanks.

推荐答案

您是否尝试过TabControl.SelectedIndex属性?如果要选择第三个选项卡,它将如下所示:

Did you try the TabControl.SelectedIndex property? If you want to select the 3rd tab, it would go like this:

tabControl1.SelectedIndex = 2;


我确实提出了一个解决方案(对此不太满意),但确实可以.

基本上,我在主模块中创建了一个索引变量,并使用它来跟踪在特定选项卡控件下选择的tabItem.然后,只要我选择其他tabControl,就使用保存的索引选择tabItem.

问候
I did come up with a solution ( not very satisfied with it) but it does work.

Basically I created an index variable in the main module and used it to keep track of the tabItem selected under a specific tab control. Then used the saved index to select the tabItem whenever I select a different tabControl.

Regards,


这篇关于WPF中的TabControl/TabItems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆