View Issue Details

IDProjectCategoryView StatusLast Update
0003965NoesisGUIUnitypublic2026-04-27 12:17
Reporteralexk Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status assignedResolutionopen 
Product Version3.2.4 
Target Version3.2.14 
Summary0003965: FocusVisualStyle doesn't get applied on initial focus
Description

If a control has a FocusVisualStyle defined for it and the focus is not coming from some other control, the FocusVisualStyle is not showing.

Steps To Reproduce

Create a button with a FocusVisualStyle defined for it and have it focus on Loaded.
Observe that the FocusVisualStyle is not showing.
Create another button, move the focus between the two and observe that once the focus is coming to the initial button from the second button, FocusVisualStyle is now showing.
Quick repro case:
XAML:
<UserControl ....

<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="MyFocusVisualStyle" TargetType="Control">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="2" BorderBrush="Red"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

</UserControl.Resources>

<Grid x:Name="MainGrid"
      HorizontalAlignment="Left" VerticalAlignment="Center"
      Height="300" Width="300"
      Background="Green"
 >
    <Button x:Name="FocusHolder"
            HorizontalAlignment="Center" VerticalAlignment="Bottom"
            Height="40" Width="70"
            Content="Focus?"
            FocusVisualStyle="{StaticResource MyFocusVisualStyle}"
            />
    <Button x:Name="InitialFocusHolder"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            Height="40" Width="170"
            Content="Focus Init"
            FocusVisualStyle="{StaticResource MyFocusVisualStyle}"
            />
    <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top"
               Text="{Binding ElementName=InitialFocusHolder, Path=IsFocused, FallbackValue=No data}" 
               Foreground="Yellow" Background="Black"
               FontSize="44"
               />
</Grid>

</UserControl>

xaml.cs:
using System.Windows.Controls;

#endif
namespace NS
{
public partial class ReproCase : UserControl
{
public ReproCase ()
{
InitializeComponent();
InitialFocusHolder.Loaded += InitialFocusHolder_Loaded;
}

    private void InitialFocusHolder_Loaded(object sender, RoutedEventArgs e)
    {
        InitialFocusHolder.Focus();
    }

#if NOESIS
private void InitializeComponent()
{
NoesisUnity.LoadComponent(this);
InitialFocusHolder = this.FindName("InitialFocusHolder") as Button;
}

    Button InitialFocusHolder;

#endif
}
}

PlatformPlayStation5

Activities

jsantos

jsantos

2025-02-17 13:24

manager   ~0010360

Thanks for the ticket.

This is not specific to PlayStation5 right?

alexk

alexk

2025-02-17 17:32

reporter   ~0010361

No, this is not specific to Playstation5.

sfernandez

sfernandez

2025-02-17 18:21

manager   ~0010362

Last edited: 2025-05-19 17:38

This is how it works by definition, when a control receives the focus from code or mouse events, it won't show the FocusVisualStyle.
Only when the control receives the focus via a keyboard/gamepad event, it will show the FocusVisualStyle.

If you want to style your controls to always show when they have logical or keyboard focus, you can do that in its template by using triggers.

<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
  <Border x:Name="bd" Background="Silver" BorderBrush="Gray" BorderThickness="1">
    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
  </Border>
  <ControlTemplate.Triggers>
    <Trigger Property="IsKeyboardFocused" Value="True">
      <Setter TargetName="bd" Property="BorderBrush" Value="Blue"/>
    </Trigger>
  </ControlTemplate.Triggers>
</ControlTemplate>

Is that what you're looking for?

alexk

alexk

2025-02-18 19:41

reporter   ~0010372

Not really, some of our controls' templates are so complex already that adding another border around isn't really feasible.
But I see your point, it looks like WPF works exactly the same way.

Issue History

Date Modified Username Field Change
2025-02-14 20:55 alexk New Issue
2025-02-14 20:55 alexk Tag Attached: FocusVisualStyle
2025-02-17 13:24 jsantos Assigned To => sfernandez
2025-02-17 13:24 jsantos Status new => assigned
2025-02-17 13:24 jsantos Target Version => 3.2.8
2025-02-17 13:24 jsantos Note Added: 0010360
2025-02-17 13:24 jsantos Status assigned => feedback
2025-02-17 17:32 alexk Note Added: 0010361
2025-02-17 17:32 alexk Status feedback => assigned
2025-02-17 18:21 sfernandez Status assigned => feedback
2025-02-17 18:21 sfernandez Note Added: 0010362
2025-02-18 19:41 alexk Note Added: 0010372
2025-02-18 19:41 alexk Status feedback => assigned
2025-05-19 17:38 sfernandez Note Edited: 0010362
2025-06-06 12:52 jsantos Target Version 3.2.8 => 3.2.9
2025-10-02 00:48 jsantos Target Version 3.2.9 => 3.2.10
2025-10-10 13:29 jsantos Category Unity3D => Unity
2025-10-20 18:25 jsantos Target Version 3.2.10 => 3.2.11
2026-01-20 19:32 jsantos Target Version 3.2.11 => 3.2.12
2026-03-04 00:39 jsantos Target Version 3.2.12 => 3.2.13
2026-04-27 12:17 jsantos Target Version 3.2.13 => 3.2.14