瀏覽代碼

Use 1 and 10 as Small/LargeChange default values.

And make them be treated as absolute values in `ScrollBar`. This is consistent with WPF and also fixes scrolling with scrollbar buttons in virtualized lists, where a unit of 1 is one item.
Steven Kirk 6 年之前
父節點
當前提交
d398d41821

+ 2 - 2
src/Avalonia.Controls/Primitives/RangeBase.cs

@@ -44,13 +44,13 @@ namespace Avalonia.Controls.Primitives
         /// Defines the <see cref="SmallChange"/> property.
         /// </summary>
         public static readonly StyledProperty<double> SmallChangeProperty =
-            AvaloniaProperty.Register<RangeBase, double>(nameof(SmallChange), 0.1);
+            AvaloniaProperty.Register<RangeBase, double>(nameof(SmallChange), 1);
 
         /// <summary>
         /// Defines the <see cref="LargeChange"/> property.
         /// </summary>
         public static readonly StyledProperty<double> LargeChangeProperty =
-            AvaloniaProperty.Register<RangeBase, double>(nameof(LargeChange), 1);
+            AvaloniaProperty.Register<RangeBase, double>(nameof(LargeChange), 10);
 
         private double _minimum;
         private double _maximum = 100.0;

+ 4 - 4
src/Avalonia.Controls/Primitives/ScrollBar.cs

@@ -216,25 +216,25 @@ namespace Avalonia.Controls.Primitives
 
         private void SmallDecrement()
         {
-            Value = Math.Max(Value - SmallChange * ViewportSize, Minimum);
+            Value = Math.Max(Value - SmallChange, Minimum);
             OnScroll(ScrollEventType.SmallDecrement);
         }
 
         private void SmallIncrement()
         {
-            Value = Math.Min(Value + SmallChange * ViewportSize, Maximum);
+            Value = Math.Min(Value + SmallChange, Maximum);
             OnScroll(ScrollEventType.SmallIncrement);
         }
 
         private void LargeDecrement()
         {
-            Value = Math.Max(Value - LargeChange * ViewportSize, Minimum);
+            Value = Math.Max(Value - LargeChange, Minimum);
             OnScroll(ScrollEventType.LargeDecrement);
         }
 
         private void LargeIncrement()
         {
-            Value = Math.Min(Value + LargeChange * ViewportSize, Maximum);
+            Value = Math.Min(Value + LargeChange, Maximum);
             OnScroll(ScrollEventType.LargeIncrement);
         }
 

+ 0 - 2
src/Avalonia.Controls/Slider.cs

@@ -47,8 +47,6 @@ namespace Avalonia.Controls
             Thumb.DragStartedEvent.AddClassHandler<Slider>(x => x.OnThumbDragStarted, RoutingStrategies.Bubble);
             Thumb.DragDeltaEvent.AddClassHandler<Slider>(x => x.OnThumbDragDelta, RoutingStrategies.Bubble);
             Thumb.DragCompletedEvent.AddClassHandler<Slider>(x => x.OnThumbDragCompleted, RoutingStrategies.Bubble);
-            SmallChangeProperty.OverrideDefaultValue<Slider>(1);
-            LargeChangeProperty.OverrideDefaultValue<Slider>(10);
         }
 
         /// <summary>