From 012e28f52bde95e82b052516691752e0524e3af0 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 23 Feb 2021 16:14:32 +0100 Subject: [PATCH] Add IsDirectionReversed to Slider. Fixes #3617. --- src/Avalonia.Controls/Slider.cs | 27 ++++++++++++++++--- src/Avalonia.Themes.Default/Slider.xaml | 4 +-- .../Controls/Slider.xaml | 4 +-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index b3dfcf3228..e02efc2bd2 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -49,6 +49,12 @@ namespace Avalonia.Controls public static readonly StyledProperty OrientationProperty = ScrollBar.OrientationProperty.AddOwner(); + /// + /// Defines the property. + /// + public static readonly StyledProperty IsDirectionReversedProperty = + Track.IsDirectionReversedProperty.AddOwner(); + /// /// Defines the property. /// @@ -127,6 +133,19 @@ namespace Avalonia.Controls set { SetValue(OrientationProperty, value); } } + /// + /// Gets or sets the direction of increasing value. + /// + /// + /// true if the direction of increasing value is to the left for a horizontal slider or + /// down for a vertical slider; otherwise, false. The default is false. + /// + public bool IsDirectionReversed + { + get { return GetValue(IsDirectionReversedProperty); } + set { SetValue(IsDirectionReversedProperty, value); } + } + /// /// Gets or sets a value that indicates whether the automatically moves the to the closest tick mark. /// @@ -202,20 +221,20 @@ namespace Avalonia.Controls { case Key.Down: case Key.Left: - MoveToNextTick(-SmallChange); + MoveToNextTick(IsDirectionReversed ? SmallChange : -SmallChange); break; case Key.Up: case Key.Right: - MoveToNextTick(SmallChange); + MoveToNextTick(IsDirectionReversed ? -SmallChange : SmallChange); break; case Key.PageUp: - MoveToNextTick(LargeChange); + MoveToNextTick(IsDirectionReversed ? -LargeChange : LargeChange); break; case Key.PageDown: - MoveToNextTick(-LargeChange); + MoveToNextTick(IsDirectionReversed ? LargeChange : -LargeChange); break; case Key.Home: diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Slider.xaml index be698608c4..bcb330f188 100644 --- a/src/Avalonia.Themes.Default/Slider.xaml +++ b/src/Avalonia.Themes.Default/Slider.xaml @@ -11,7 +11,7 @@ - + @@ -46,7 +46,7 @@ - + diff --git a/src/Avalonia.Themes.Fluent/Controls/Slider.xaml b/src/Avalonia.Themes.Fluent/Controls/Slider.xaml index 1f25b7d90d..33f0a76423 100644 --- a/src/Avalonia.Themes.Fluent/Controls/Slider.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/Slider.xaml @@ -62,7 +62,7 @@ - + @@ -124,7 +124,7 @@ - +