2010-03-17 3 views
0

WPF의 버그처럼 보이지만 다른 사람이 이에 대한 답변을 가지고 있습니다. 편집 가능한 ComboBox에 대한 DataTrigger가 있습니다. 내 TabControl의 첫 번째 TabItem에서 작동하지만 두 번째 TabControl에서는 작동하지 않습니다. 두 번째 TabItem으로 첫 번째 항목을 전환하면 "두 번째 항목"이 작동합니다. ComboBox (ComboBox.Style ...)에 정확하게 스타일을 지정하면 같은 효과가 발생합니다. 이 버그가 대신DataTrigger는 TabControl의 첫 번째 TabItem에서만 작동합니다.

사용처럼

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

답변

1

것 같습니다 :

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