Skip to content

Commit

Permalink
Execute on start observing
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Oct 30, 2024
1 parent 9f9150d commit 194de33
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Avalonia.Xaml.Interactions.Responsive/AdaptiveBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ private IDisposable ObserveBounds(Control sourceControl)
throw new ArgumentNullException(nameof(sourceControl));
}

Execute(sourceControl, Setters, sourceControl.GetValue(Visual.BoundsProperty));

return sourceControl.GetObservable(Visual.BoundsProperty)
.Subscribe(new AnonymousObserver<Rect>(bounds => ValueChanged(sourceControl, Setters, bounds)));
.Subscribe(new AnonymousObserver<Rect>(bounds =>
{
Execute(sourceControl, Setters, bounds);
}));
}

private void ValueChanged(Control? sourceControl, AvaloniaList<AdaptiveClassSetter>? setters, Rect bounds)
private void Execute(Control? sourceControl, AvaloniaList<AdaptiveClassSetter>? setters, Rect bounds)
{
if (sourceControl is null || setters is null)
{
Expand Down

0 comments on commit 194de33

Please sign in to comment.