diff --git a/src/Avalonia.Xaml.Interactions.Custom/FocusBehavior.cs b/src/Avalonia.Xaml.Interactions.Custom/FocusBehavior.cs
index 3786e5f2..b367fbcc 100644
--- a/src/Avalonia.Xaml.Interactions.Custom/FocusBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.Custom/FocusBehavior.cs
@@ -31,27 +31,27 @@ public bool IsFocused
///
protected override void OnAttached(CompositeDisposable disposables)
{
- if (AssociatedObject is not null)
- {
- disposables.Add(AssociatedObject.GetObservable(Avalonia.Input.InputElement.IsFocusedProperty)
- .Subscribe(new AnonymousObserver(
- focused =>
- {
- if (!focused)
- {
- IsFocused = false;
- }
- })));
+ if (AssociatedObject is not null)
+ {
+ disposables.Add(AssociatedObject.GetObservable(Avalonia.Input.InputElement.IsFocusedProperty)
+ .Subscribe(new AnonymousObserver(
+ focused =>
+ {
+ if (!focused)
+ {
+ SetCurrentValue(IsFocusedProperty, false);
+ }
+ })));
- disposables.Add(this.GetObservable(IsFocusedProperty)
- .Subscribe(new AnonymousObserver(
- focused =>
- {
- if (focused)
- {
- AssociatedObject.Focus();
- }
- })));
- }
+ disposables.Add(this.GetObservable(IsFocusedProperty)
+ .Subscribe(new AnonymousObserver(
+ focused =>
+ {
+ if (focused)
+ {
+ AssociatedObject.Focus();
+ }
+ })));
+ }
}
}