从选项卡式布局组中获取SelectedTabIndex

时间:2013-08-28 12:53:44

标签: wpf devexpress

我需要一种方法来了解选项卡式布局组中选择的选项卡。 这是我的观点代码:

<dxlc:LayoutGroup View="Tabs" Width="{Binding ElementName=MainGroup, Path=ActualWidth, Mode=OneWay}" >
                    <dxlc:LayoutGroup Header="Service lines">
                        <Grid>
                        </Grid>
                    </dxlc:LayoutGroup>
                    <dxlc:LayoutGroup Header="Cargo">
                    <Grid>
                    </Grid>
                </dxlc:LayoutGroup>

当我使用属性SelectedTabIndex时,我总是会检索0。有什么想法吗?

迎接

1 个答案:

答案 0 :(得分:0)

我对这个DevExpress控件一无所知,但我可以阅读......在查看了有关此LayoutGroup控件的文档之后,我注意到了一些事情:

来自DevExpress的LayoutGroup.SelectedTabIndex Property页:

  

要为LayoutGroup对象启用选项卡式界面,请将GroupBorderStyle属性设置为GroupBorderStyle.Tabbed。

你做到了吗,因为它看起来不像吗?

我想你会使用这个属性:

int index = layoutGroup.SelectedTabIndex;

在同一页面上,它还说:

  

要获取所选项目,请使用SelectedItem属性。

所以,如果上面的属性真的不起作用,那么也许你可以尝试这样的事情:

var selectedTab = tabItem1;
if (layoutGroup.SelectedItem == tabItem2) selectedTab = tabItem2;
else if (layoutGroup.SelectedItem == tabItem3) selectedTab = tabItem3;
...
else if (layoutGroup.SelectedItem == tabItem10) selectedTab = tabItem10;

// do something with the selected tab item here