@@ -116,7 +116,7 @@ public Rect MakeVisible(Visual visual, Rect rectangle)
116116
117117 public void SetHorizontalOffset ( double offset )
118118 {
119- var value = Math . Max ( 0 , offset ) ;
119+ var value = Math . Max ( 0 , Math . Min ( offset , ExtentWidth - ViewportWidth ) ) ;
120120
121121 if ( value != HorizontalOffset )
122122 {
@@ -127,7 +127,7 @@ public void SetHorizontalOffset(double offset)
127127
128128 public void SetVerticalOffset ( double offset )
129129 {
130- var value = Math . Max ( 0 , offset ) ;
130+ var value = Math . Max ( 0 , Math . Min ( offset , ExtentHeight - ViewportHeight ) ) ;
131131
132132 if ( value != VerticalOffset )
133133 {
@@ -157,9 +157,6 @@ protected override Size MeasureOverride(Size availableSize)
157157 height += child . DesiredSize . Height ;
158158 }
159159
160- ExtentWidth = maxWidth ;
161- ExtentHeight = height ;
162-
163160 UpdateScrollInfo ( new Size ( maxWidth , height ) , availableSize ) ;
164161
165162 return new Size (
@@ -185,17 +182,11 @@ protected override Size ArrangeOverride(Size finalSize)
185182
186183 void UpdateScrollInfo ( Size extent , Size viewport )
187184 {
188- var changed = extent . Width != ExtentWidth ||
189- extent . Height != ExtentHeight ||
190- viewport . Width != ViewportWidth ||
191- viewport . Height != ViewportHeight ;
192-
193185 ExtentWidth = extent . Width ;
194186 ExtentHeight = extent . Height ;
195187 ViewportWidth = viewport . Width ;
196188 ViewportHeight = viewport . Height ;
197-
198- if ( changed ) ScrollOwner ? . InvalidateScrollInfo ( ) ;
189+ ScrollOwner ? . InvalidateScrollInfo ( ) ;
199190 }
200191 }
201192}
0 commit comments