2010-03-17 8 views
0

Cela ressemble à un bug dans WPF, mais peut-être que quelqu'un a une réponse à cela. J'ai un DataTrigger pour un ComboBox modifiable. Cela fonctionne sur le premier TabItem de mon TabControl, mais pas sur le second. Si vous changez le premier avec le second TabItem, le "second" fonctionnera. Le même effet se produit lorsque vous donnez le style exactement au ComboBox (ComboBox.Style ...).DataTrigger ne fonctionne que sur le premier TabItem dans TabControl

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

Répondre

1

il semble que c'est un bug

utiliser:

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