问题描述
喜的朋友,我是新来的Silverlight应用程序。我创建的TabControl有4 TabItem的.Name点的的TabItems就像TAB1 TAB2 TAB3 TAB4。我需要在运行项目增加一个TabItem的。它成功添加通过下面的代码
Hi friends, i am new to silverlight app. i have created tabcontrol with 4 tabitem .Name of the tabitems are like tab1 tab2 tab3 tab4 . i need to add one more tabitem at run item . it added successfully by following code
TabItem的TabItem的=新TabItem的();结果
tabItem.Header =tab5 ;结果
tabControl.Items.Add(TabItem的);
我的问题是,添加旁边TAB4 tab5。但我的要求是,它应该加入的下我的当前选择的TabItem的。也就是说,如果在上午TAB1它应该TAB1和TAB2等之间。我已经搜查MSDN和护目镜没有得到anything.Possible给予一定的指导,让我的解决方案。我不喜欢用第三方控件。请指导我完成这个问题。
my problem is, tab5 added next to tab4 . but my requirement is ,it should added next my current selected tabitem .that is, if am in tab1 it should between tab1 and tab2 and so on. i have searched in msdn and goggle didn't get anything.Possible give some guidance to get my solution. i don't like to use third parties control .Please guide me to finish this issue
推荐答案
的的TabControl
公开了一个的SelectedIndex
属性,这会告诉你 TabControl.Items 内当前可见的选项卡的索引code>,只需
插入
的索引之后。例如:
The TabControl
exposes a SelectedIndex
property, this will tell you the index of the currently visible tab within the TabControl.Items
, simply Insert
after that index. For example:
tabControl.Items.Insert(tabControl.SelectedIndex + 1, tabItem);
这篇关于在的TabControl添加TabItem的使用在Silverlight的运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!