Tab SelectionChanged fired despite no change in TabItem selected
My question is this. I have a tab control which hosts a listbox and a combobox on separate tabs. I have SelectionChanged events hooked to the three controls : tabcontrol, listbox and combobox.
As I change tab, as expected, the tabSelChanged is fired. Now, the weird thing is, if I were to change my selection of either the listbox or the combobox - not only the corresponding events for the controls are being fired (listboxSelChanged / comboSelChanged), the tabSelChanged is also fired although there is no change in the selected tab. I was expecting that tabSelChanged to be fired only when different tabItem is selected.
Anyone care to shed some light on this behavior? Thank you.
<TabControl IsSynchronizedWithCurrentItem="False" SelectionChanged="tabSelChanged">
<TabItem Header="TabItem1">
<Grid>
<ListBox HorizontalAlignment="Left" Margin="139,62.723,0,160" Width="112" IsSynchronizedWithCurrentItem="False" SelectionChanged="listboxSelChanged">
<ListBoxItem Content="ListBoxItem1"/>
<ListBoxItem Content="ListBoxItem2"/>
<ListBoxItem Content="ListBoxItem3"/>
</ListBox>
</Grid>
</TabItem>
<TabItem Header="TabItem2">
<Grid>
<ComboBox Width="100" Height="30" IsSynchronizedWithCurrentItem="False" SelectionChanged="comboSelChanged">
<ComboBoxItem Content="ComboBoxItem1"/>
<ComboBoxItem Content="ComboBoxItem2"/>
<ComboBoxItem Content="ComboBoxItem3"/>
</ComboBox>
</Grid>
</TabItem>
</TabControl>
</Grid>
private void tabSelChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
Debug.Print("MainTab");
}
private void comboSelChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
Debug.Print("MainCombo");
}
private void listboxSelChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
Debug.Print("MainListBox");
}

