views:

121

answers:

1

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.Style ...).

<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>

A: 

it seems like it is a bug

instead use:

Style.Triggers>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BitmapEffect">
                    <Setter.Value>
                        <OuterGlowBitmapEffect GlowColor="Red" GlowSize="5" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
Oggy