You could try to refer to the code below.
Xaml:
<Window.DataContext >
<local:ViewModel />
</Window.DataContext>
<Grid>
<ComboBox local:FocusExtension.IsFocused="{Binding IsFocused}" ItemsSource="{Binding List}" Height="80" SelectedIndex=" 0">
<ComboBox.Style>
<Style TargetType="ComboBox">
<Setter Property="Foreground" Value="Red" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Foreground" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
</Grid>
Codebehind:
public class ViewModel
{
public ObservableCollection<string> List{get;set;} = new ObservableCollection<string>();
public ViewModel()
{
List.Add( "user1" );
List.Add( "user2" );
List.Add( "user3" );
List.Add( "user4" );
}
}
The result:
Update:
The complete code:
271287-comboboxforegroundtrigger.txt
The result:
----------------------------------------------------------------------------
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.