1) You can't set the
UIElement.IsFocused property[
^]; it's read-only.
2) Your style triggers bind to the
UIElement.IsFocused
property,
not your custom
FocusExtension.IsFocused
property.
3) Your
OnIsFocusedPropertyChanged
method will only be called when the
FocusExtension.IsFocused
property is changed. Since you've bound that to the
UIElement.IsFocused
property, it will be called when the control gains or loses focus. So your custom property will only be set to
false
when the control gains focus whilst the mouse is directly over it.
This seems like an
XY problem[
^]; rather than telling us what problem you're actually trying to solve, you're asking us to help you fix a problem with your chosen solution to the original problem.
If you're just trying to change the style when the mouse is over the control, then use a trigger:
<ComboBox.Style>
<Setter Property="Foreground" Value="Red" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Foreground" Value="Green" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
Otherwise, you'll need to explain precisely what you are trying to do.