【问题标题】:How can I close all tabs in TabControlEx?如何关闭 TabControlEx 中的所有选项卡?
【发布时间】:2011-11-30 07:09:15
【问题描述】:

我正在使用 WPF 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>

有什么建议吗?

非常感谢您的帮助

【问题讨论】:

  • 什么是 TabControlEx ???

标签: .net wpf mvvm command


【解决方案1】:

如果它是正常的TabControl,那么我假设你有:

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

一个选项卡控件,其集合设置为项目源属性

Execute 操作上为CloseWorkSpaceCommand 设置MyTabs=new List&lt;Tab&gt;()

MyTabs 将是您视图的 ViewModel 中的一个属性。 ViewModel 应该实现INotifyPropertyChanged

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-17
    • 1970-01-01
    相关资源
    最近更新 更多