Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Update FocusBehavior.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes authored Apr 2, 2024
1 parent 707be83 commit a6d81d1
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/Avalonia.Xaml.Interactions.Custom/FocusBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ public bool IsFocused
/// <param name="disposables"></param>
protected override void OnAttached(CompositeDisposable disposables)
{
if (AssociatedObject is not null)
{
disposables.Add(AssociatedObject.GetObservable(Avalonia.Input.InputElement.IsFocusedProperty)
.Subscribe(new AnonymousObserver<bool>(
focused =>
{
if (!focused)
{
IsFocused = false;
}
})));
if (AssociatedObject is not null)
{
disposables.Add(AssociatedObject.GetObservable(Avalonia.Input.InputElement.IsFocusedProperty)
.Subscribe(new AnonymousObserver<bool>(
focused =>
{
if (!focused)
{
SetCurrentValue(IsFocusedProperty, false);
}
})));

disposables.Add(this.GetObservable(IsFocusedProperty)
.Subscribe(new AnonymousObserver<bool>(
focused =>
{
if (focused)
{
AssociatedObject.Focus();
}
})));
}
disposables.Add(this.GetObservable(IsFocusedProperty)
.Subscribe(new AnonymousObserver<bool>(
focused =>
{
if (focused)
{
AssociatedObject.Focus();
}
})));
}
}
}

0 comments on commit a6d81d1

Please sign in to comment.