开发者

DataTrigger only works on first TabItem in TabControl

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>
            <D开发者_JS百科ataTrigger 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>


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜