DataTrigger only works on first TabItem in TabControl

Posted by JustusJonas on Stack Overflow See other posts from Stack Overflow or by JustusJonas
Published on 2010-03-17T09:56:55Z Indexed on 2010/03/17 10:01 UTC
Read the original article Hit count: 570

Hi! It seems like a bug in WPF, but maybe someone has an answers to this. I have a DataTrigger for an editable ComboBox. It works on the first TabItem of my TabControl, but not on the second. If you switch the first with the second TabItem, the "second" will work. The same effect happens when you give the style exactly to the ComboBox (ComboBox.Stye ...).

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="Height" Value="25" />
        <Setter Property="Width" Value="125" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding ElementName=PART_EditableTextBox, Path=IsFocused}" Value="True">
                <Setter Property="BitmapEffect">
                    <Setter.Value>
                        <OuterGlowBitmapEffect GlowColor="Red" GlowSize="5" />
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
<Grid x:Name="LayoutRoot">
    <TabControl>
        <TabItem Header="TabItem1">
            <Grid>
                <ComboBox IsEditable="True"/>
            </Grid>
        </TabItem>
        <TabItem Header="TabItem2">
            <Grid>
                <ComboBox IsEditable="True"/>
            </Grid>
        </TabItem>
    </TabControl>
</Grid>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about tabcontrol