2013-08-28 18 views
0

我需要一種方法來了解在選項卡式佈局組內選擇了哪個選項卡。 這是我的看法的代碼:從選項卡式佈局組中獲取SelectedTabIndex

<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> 

我總是retreive 0,當我使用屬性SelectedTabIndex。有任何想法嗎?

電賀

回答

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 
+0

沒有財產「GroupBorderStyle」可用,我使用的瀏覽= 「標籤」insetad。但奇怪的是,我總是收到tabindex 0.並且每個佈局組,也是頭佈局組下的一個選項卡,也有SelectedTabIndex 0,就像父項一樣。所以不知道我在做什麼錯.. –

+0

有一個['LayoutGroup.GroupBorderStyle'](http://documentation.devexpress.com/#WPF/DevExpressXpfDockingLayoutGroup_GroupBorderStyletopic)屬性的文檔頁面,所以如果你真的*你的'LayoutGroup'對象沒有一個,那麼我會聯繫'DevExpress'而不是StackOverflow用戶。 – Sheridan

+0

我會在論壇上發表一個主題,謝謝!)! –