0

これは WPF のバグのようですが、誰かがこれに対する答えを持っているかもしれません。編集可能な ComboBox の DataTrigger があります。私のTabControlの最初のTabItemでは機能しますが、2番目では機能しません。最初のものを2番目のTabItemに切り替えると、「2番目」が機能します。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>

4

1 に答える 1

1

バグのようです

代わりに次を使用します。

Style.Triggers>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BitmapEffect">
                    <Setter.Value>
                        <OuterGlowBitmapEffect GlowColor="Red" GlowSize="5" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
于 2010-03-18T11:27:27.643 に答える