I have what to some may seem like a simple problem and despite my best efforts, I have been unable to 'fix' this problem:
I have a custom style for a TextBox, defined in a 'common' assembly; this style overrides the default and is thus used every time someone uses a TextBox. The problem is that when the style is applied, the GotFocus, IsKeyboardFocusWithinChanged and PreviewGotKeyboardFocus events are -not- fired any longer. I've verified that this only happens when this style is applied (If I comment it out and run the application, the events are fired correctly).
So my question is essentially, has anyone experienced anything similar? And if so, does anyone know of a solution for this problem?
The style is as follows (The static resources a simple SolidColorBrushes):
<Style TargetType="{x:Type TextBox}" x:Key="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="BorderBrush" Value="{StaticResource BrushBorder}"/> <Setter Property="ContextMenu" Value="{StaticResource TextBoxContextMenu}" /> <Setter Property="Foreground" Value="{StaticResource BrushForeground}" /> <Setter Property="SelectionBrush" Value="{StaticResource BrushHighlight}" /> <Setter Property="Background" Value="{StaticResource BrushBackground}"/> <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Border BorderThickness="1" x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> <ScrollViewer x:Name="PART_ContentHost" Margin="0" /> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value="True"> <Setter Property="Background" Value="{StaticResource BrushLightBg}" /> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="{StaticResource BrushMouseoverBackground}" /> </Trigger> </Style.Triggers> </Style>