diff --git a/src/Avalonia.Controls/ScrollViewer.cs b/src/Avalonia.Controls/ScrollViewer.cs index 058c11c9ee..d77833b32e 100644 --- a/src/Avalonia.Controls/ScrollViewer.cs +++ b/src/Avalonia.Controls/ScrollViewer.cs @@ -602,16 +602,19 @@ namespace Avalonia.Controls private void RaiseScrollChanged() { - var e = new ScrollChangedEventArgs( - new Vector(Extent.Width - _oldExtent.Width, Extent.Height - _oldExtent.Height), - Offset - _oldOffset, - new Vector(Viewport.Width - _oldViewport.Width, Viewport.Height - _oldViewport.Height)); + var extentDelta = new Vector(Extent.Width - _oldExtent.Width, Extent.Height - _oldExtent.Height); + var offsetDelta = Offset - _oldOffset; + var viewportDelta = new Vector(Viewport.Width - _oldViewport.Width, Viewport.Height - _oldViewport.Height); - OnScrollChanged(e); + if (extentDelta != default || offsetDelta != default || viewportDelta != default) + { + var e = new ScrollChangedEventArgs(extentDelta, offsetDelta, viewportDelta); + OnScrollChanged(e); - _oldExtent = Extent; - _oldOffset = Offset; - _oldViewport = Viewport; + _oldExtent = Extent; + _oldOffset = Offset; + _oldViewport = Viewport; + } } } } diff --git a/tests/Avalonia.Layout.UnitTests/LayoutableTests.cs b/tests/Avalonia.Layout.UnitTests/LayoutableTests.cs index 7013e93a43..a21c8d589d 100644 --- a/tests/Avalonia.Layout.UnitTests/LayoutableTests.cs +++ b/tests/Avalonia.Layout.UnitTests/LayoutableTests.cs @@ -213,9 +213,7 @@ namespace Avalonia.Layout.UnitTests { Child = border1 = new Border { - Child = border2 = new Border - { - } + Child = border2 = new Border(), }, LayoutManager = layoutManager, };