参考:WPF TabControl SelectionChanged 重复执行的问题 - 一!雨 - 博客园 (cnblogs.com)
添加如下代码
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { e.Handled = true; }
如果采用MVVM模式,在当前页面中添加如下代码(注意不是ViewModel中)
<TabControl SelectionChanged="TabControl_OnSelectionChanged"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <command:EventToCommand Command="{Binding TabSelectTestCommand}" /> </i:EventTrigger> </i:Interaction.Triggers> <TabItem Header="dd"></TabItem> </TabControl> private void TabControl_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.Source.GetType() != typeof (TabControl)) { e.Handled = true; } }
标签:Handled,ComboBox,SelectionChangedEventArgs,SelectionChanged,WPF,TabControl From: https://www.cnblogs.com/ZY2022/p/17674331.html