【发布时间】:2012-11-17 06:21:58
【问题描述】:
我有一个 WPF 应用程序,在主窗口中我有一个 TabControl。
我希望TabItems 在被选中时触发我在ViewModel 中的RelayCommand(每个TabItem 有不同的命令)。
我不想为命令CanExecute 函数中设置的某些条件选择TabItem。
这可能吗?
【问题讨论】:
-
如果我理解正确,您需要做的是: 1. 防止某些
TabItems被选中; based on some logic (in which case see: stackoverflow.com/questions/4851315/…) 2._do something_ when aTabItemis selected (in which case I think you can simply handleSelectionChangedevent)