@@ -907,7 +907,7 @@ protected override void OnApplyTemplate()
907
907
908
908
OnBringIntoViewOnFocusChangeChangedPartial ( BringIntoViewOnFocusChange ) ;
909
909
910
- ResetScrollIndicator ( forced : true ) ;
910
+ PrepareScrollIndicator ( ) ;
911
911
}
912
912
913
913
partial void OnApplyTemplatePartial ( ) ;
@@ -1368,16 +1368,30 @@ private bool ChangeViewCore(
1368
1368
return ChangeViewNative ( horizontalOffset , verticalOffset , zoomFactor , disableAnimation ) ;
1369
1369
}
1370
1370
1371
- #region Scroll indicators visual states (Managed scroll bars only)
1371
+ #region Scroll indicators visual states (Managed scroll bars only)
1372
+ private static readonly TimeSpan _indicatorResetDelay = FeatureConfiguration . ScrollViewer . DefaultAutoHideDelay ?? TimeSpan . FromSeconds ( 4 ) ;
1373
+ private static readonly bool _indicatorResetDisabled = _indicatorResetDelay == TimeSpan . MaxValue ;
1372
1374
private DispatcherQueueTimer ? _indicatorResetTimer ;
1373
1375
private string ? _indicatorState ;
1374
1376
1377
+ private void PrepareScrollIndicator ( ) // OnApplyTemplate
1378
+ {
1379
+ if ( _indicatorResetDisabled )
1380
+ {
1381
+ ShowScrollIndicator ( PointerDeviceType . Mouse , forced : true ) ;
1382
+ }
1383
+ else
1384
+ {
1385
+ ResetScrollIndicator ( forced : true ) ;
1386
+ }
1387
+ }
1388
+
1375
1389
private static void ShowScrollIndicator ( object sender , PointerRoutedEventArgs e ) // OnPointerMove
1376
1390
=> ( sender as ScrollViewer ) ? . ShowScrollIndicator ( e . Pointer . PointerDeviceType ) ;
1377
1391
1378
- private void ShowScrollIndicator ( PointerDeviceType type )
1392
+ private void ShowScrollIndicator ( PointerDeviceType type , bool forced = false )
1379
1393
{
1380
- if ( ! ComputedIsVerticalScrollEnabled && ! ComputedIsHorizontalScrollEnabled )
1394
+ if ( ! forced && ! ComputedIsVerticalScrollEnabled && ! ComputedIsHorizontalScrollEnabled )
1381
1395
{
1382
1396
return ;
1383
1397
}
@@ -1393,13 +1407,18 @@ private void ShowScrollIndicator(PointerDeviceType type)
1393
1407
_indicatorState = indicatorState ;
1394
1408
}
1395
1409
1410
+ if ( _indicatorResetDisabled )
1411
+ {
1412
+ return ;
1413
+ }
1414
+
1396
1415
// Automatically hide the scroll indicator after a delay without any interaction
1397
1416
if ( _indicatorResetTimer == null )
1398
1417
{
1399
1418
var weakRef = WeakReferencePool . RentSelfWeakReference ( this ) ;
1400
1419
_indicatorResetTimer = new DispatcherQueueTimer
1401
1420
{
1402
- Interval = TimeSpan . FromSeconds ( 4 ) ,
1421
+ Interval = _indicatorResetDelay ,
1403
1422
IsRepeating = false
1404
1423
} ;
1405
1424
_indicatorResetTimer . Tick += ( snd , e ) => ( weakRef . Target as ScrollViewer ) ? . ResetScrollIndicator ( ) ;
@@ -1412,6 +1431,11 @@ private static void ResetScrollIndicator(object sender, RoutedEventArgs _) // On
1412
1431
1413
1432
private void ResetScrollIndicator ( bool forced = false )
1414
1433
{
1434
+ if ( _indicatorResetDisabled )
1435
+ {
1436
+ return ;
1437
+ }
1438
+
1415
1439
_indicatorResetTimer ? . Stop ( ) ;
1416
1440
1417
1441
if ( ! forced && ( ( _horizontalScrollbar ? . IsPointerOver ?? false ) || ( _verticalScrollbar ? . IsPointerOver ?? false ) ) )
@@ -1447,6 +1471,6 @@ private void HideScrollBarSeparator(object sender, PointerRoutedEventArgs e) //
1447
1471
VisualStateManager . GoToState ( this , VisualStates . ScrollBarsSeparator . Collapsed , true ) ;
1448
1472
}
1449
1473
}
1450
- #endregion
1474
+ #endregion
1451
1475
}
1452
1476
}
0 commit comments