@@ -157,9 +157,6 @@ private bool AssignAnimation()
157
157
headerElement . SizeChanged -= ScrollHeader_SizeChanged ;
158
158
headerElement . SizeChanged += ScrollHeader_SizeChanged ;
159
159
160
- _scrollViewer . GotFocus -= ScrollViewer_GotFocus ;
161
- _scrollViewer . GotFocus += ScrollViewer_GotFocus ;
162
-
163
160
var compositor = _scrollProperties . Compositor ;
164
161
165
162
if ( _animationProperties is null )
@@ -202,9 +199,6 @@ private void RemoveAnimation()
202
199
if ( HeaderElement is FrameworkElement element )
203
200
element . SizeChanged -= ScrollHeader_SizeChanged ;
204
201
205
- if ( _scrollViewer is not null )
206
- _scrollViewer . GotFocus -= ScrollViewer_GotFocus ;
207
-
208
202
StopAnimation ( ) ;
209
203
}
210
204
@@ -231,38 +225,5 @@ private void ScrollHeader_SizeChanged(object sender, SizeChangedEventArgs e)
231
225
{
232
226
AssignAnimation ( ) ;
233
227
}
234
-
235
- private void ScrollViewer_GotFocus ( object sender , RoutedEventArgs e )
236
- {
237
- var scroller = ( ScrollViewer ) sender ;
238
-
239
- object focusedElement ;
240
-
241
- if ( IsXamlRootAvailable && scroller . XamlRoot is not null )
242
- {
243
- focusedElement = FocusManager . GetFocusedElement ( scroller . XamlRoot ) ;
244
- }
245
- else
246
- {
247
- focusedElement = FocusManager . GetFocusedElement ( ) ;
248
- }
249
-
250
- // To prevent Popups (Flyouts...) from triggering the autoscroll, we check if the focused element has a valid parent.
251
- // Popups have no parents, whereas a normal Item would have the ListView as a parent.
252
- if ( focusedElement is UIElement element && VisualTreeHelper . GetParent ( element ) is not null )
253
- {
254
- // NOTE: Ignore if element is child of header
255
- if ( ! element . FindAscendants ( ) . Any ( x => x == HeaderElement ) )
256
- {
257
- FrameworkElement header = ( FrameworkElement ) HeaderElement ;
258
-
259
- var point = element . TransformToVisual ( scroller ) . TransformPoint ( new Point ( 0 , 0 ) ) ;
260
-
261
- // NOTE: Do not change scroller horizontal offset
262
- if ( point . Y < header . ActualHeight )
263
- scroller . ChangeView ( scroller . HorizontalOffset , scroller . VerticalOffset - ( header . ActualHeight - point . Y ) , 1 , false ) ;
264
- }
265
- }
266
- }
267
228
}
268
229
}
0 commit comments