Why TabControl.SelectedContent != (TabControl.SelectedItem as TabItem).Content ?

Posted by CannibalSmith on Stack Overflow See other posts from Stack Overflow or by CannibalSmith
Published on 2010-03-31T09:35:58Z Indexed on 2010/04/01 0:03 UTC
Read the original article Hit count: 760

Filed under:
|

The following sample shouldn't beep (in my opinion) but it does. Why? Does that mean the SelectedContent property is useless? Is it a bug in WPF?

<TabControl SelectionChanged="TabControl_SelectionChanged">
    <TabItem Header="Tab 1">
        <Grid/>
    </TabItem>
    <TabItem Header="Tab 2">
        <Grid/>
    </TabItem>
</TabControl>

 

void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    var t = sender as TabControl;
    if (t.SelectedContent != (t.SelectedItem as TabItem).Content) Console.Beep();
}

© Stack Overflow or respective owner

Related posts about wpf

Related posts about tabcontrol