Wpf ListBox Trigger not working for IsFocused Property.
- by viky
I want to style my ListBox and displaying some Border around it, i want to hide this Border when ListBox gets focus,
<Trigger Property="IsFocused" Value="True">
<Setter Property="Visibility" TargetName="border" Value="Collapsed"/>
</Trigger>
Same thing i m using in TextBox also and it is working properly,
why this Trigger not working for ListBox?
Edit:
i am having this Style for my ListBox
<ControlTemplate TargetType="{x:Type local:ListBox}">
<Border SnapsToDevicePixels="true" x:Name="Bd" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1">
<Grid>
<local:ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</local:ScrollViewer>
<Border CornerRadius="5" Background="Red" x:Name="border">
<TextBlock VerticalAlignment="Center" FontWeight="Bold" Foreground="White" Text="{TemplateBinding Message}" FontFamily="Courier New" />
</Border>
</Grid>
</Border>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Visibility" TargetName="border" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
</ControlTemplate.Triggers>