2011-10-03 62 views
0

我正在使用WPF TabControlEx(關閉標籤)。如何關閉TabControlEx中的所有選項卡?

我正在尋找一種方式來關閉標籤中的ContextMenu的所有選項卡。

我正在使用MVVM。

<Style TargetType="{x:Type TabItem}"> 
    ... 
    <Grid.ContextMenu> 
    <ContextMenu> 
     <MenuItem Header="Close tab" Command="{Binding CloseWorkSpaceCommand}" /> <!-- OK --> 
     <Separator /> 
     <MenuItem Header="Close other tabs" Command="{Binding ...Command}" /> 
     <Separator /> 
     <MenuItem Header="Close all tabs" Command="{Binding ...Command}" /> 
    </ContextMenu> 
    </Grid.ContextMenu> 

有什麼建議嗎?

非常感謝你們的幫助

+0

什麼是TabControlEx? – Ankesh

回答

0

如果其正常TabControl然後我假設你有:

<TabControl ItemsSource="{Binding Path=MyTabs}"></TabControl> 

一個標籤控件設置爲項目源屬性

集的集合MyTabs=new List<Tab>()Execute行動CloseWorkSpaceCommand

MyTabs將是一個屬性在View的ViewModel中。 ViewModel應該實施INotifyPropertyChanged

相關問題