Very scary question, I used to feel that it was Microsoft's bug.
The problem is this: there is a ComboBox control in the TabItem under my TabControl, and for some reason the TabControl selectionchanged event needs to be performed, but in a more bizarre way, Whenever I select an item in the ComboBox, that is, when the SelectionChanged event of the ComboBox changes, TabControl's SelectionChanged event is executed at the same time, baffled, and later found the relevant reason on the Internet, As follows:
This is because of routedevents.to solve it either handle the selectionchanged of the ComboBox.
In the function handler of the selectionchanged for ComboBox just give E.handled=true;
private void Combobox_selectionchanged (object sender, SelectionChangedEventArgs e) |
{ |
E.handled = true; |
} |
if u dont want to does this get the OriginalSource property of SelectionChangedEventArgs in the TabControl selectionchanged Handler. This would show whether it is the from TabControl or ComboBox.
It is probably said that Microsoft default events can be passed, if you do not want to pass this, set E. Handled=true terminates the delivery.
Well, the final solution can only be set e.handled=true in the SelectionChanged event of the ComboBox, and not just the ComboBox, but also the Listbox,listview, Controls with SelectionChanged events, such as the DataGrid.
WPF TabControl selectionchanged Recurring issues