diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RangeSelector/RangeSelectorPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RangeSelector/RangeSelectorPage.xaml
index f6e6dad2b0f..42ab1f6eebf 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RangeSelector/RangeSelectorPage.xaml
+++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RangeSelector/RangeSelectorPage.xaml
@@ -21,14 +21,17 @@
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.cs b/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.cs
index 702dedf591d..adab3562089 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.cs
@@ -54,6 +54,11 @@ public class RangeSelector : Control
///
public static readonly DependencyProperty RangeMaxProperty = DependencyProperty.Register(nameof(RangeMax), typeof(double), typeof(RangeSelector), new PropertyMetadata(1.0, RangeMaxChangedCallback));
+ ///
+ /// Identifies the IsTouchOptimized dependency property.
+ ///
+ public static readonly DependencyProperty IsTouchOptimizedProperty = DependencyProperty.Register(nameof(IsTouchOptimized), typeof(bool), typeof(RangeSelector), new PropertyMetadata(false, IsTouchOptimizedChangedCallback));
+
private const double Epsilon = 0.01;
private Border _outOfRangeContentContainer;
@@ -174,6 +179,8 @@ protected override void OnApplyTemplate()
IsEnabledChanged += RangeSelector_IsEnabledChanged;
+ ArrangeForTouch();
+
base.OnApplyTemplate();
}
@@ -562,6 +569,85 @@ private static void RangeMaxChangedCallback(DependencyObject d, DependencyProper
}
}
+ ///
+ /// Gets or sets a value indicating whether the control is optimized for touch use.
+ ///
+ ///
+ /// The value for touch optimization.
+ ///
+ public bool IsTouchOptimized
+ {
+ get
+ {
+ return (bool)GetValue(IsTouchOptimizedProperty);
+ }
+
+ set
+ {
+ SetValue(IsTouchOptimizedProperty, value);
+ }
+ }
+
+ private static void IsTouchOptimizedChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var rangeSelector = d as RangeSelector;
+ if (rangeSelector == null)
+ {
+ return;
+ }
+
+ rangeSelector.ArrangeForTouch();
+ }
+
+ private void ArrangeForTouch()
+ {
+ if (_containerCanvas == null)
+ {
+ return;
+ }
+
+ if (IsTouchOptimized)
+ {
+ if (_outOfRangeContentContainer != null)
+ {
+ _outOfRangeContentContainer.Height = 44;
+ }
+
+ if (_minThumb != null)
+ {
+ _minThumb.Width = _minThumb.Height = 44;
+ _minThumb.Margin = new Thickness(-20, 0, 0, 0);
+ }
+
+ if (_maxThumb != null)
+ {
+ _maxThumb.Width = _maxThumb.Height = 44;
+ _maxThumb.Margin = new Thickness(-20, 0, 0, 0);
+ }
+ }
+ else
+ {
+ if (_outOfRangeContentContainer != null)
+ {
+ _outOfRangeContentContainer.Height = 24;
+ }
+
+ if (_minThumb != null)
+ {
+ _minThumb.Width = 8;
+ _minThumb.Height = 24;
+ _minThumb.Margin = new Thickness(-8, 0, 0, 0);
+ }
+
+ if (_maxThumb != null)
+ {
+ _maxThumb.Width = 8;
+ _maxThumb.Height = 24;
+ _maxThumb.Margin = new Thickness(-8, 0, 0, 0);
+ }
+ }
+ }
+
private void SyncThumbs()
{
if (_containerCanvas == null)
@@ -574,6 +660,7 @@ private void SyncThumbs()
Canvas.SetLeft(_minThumb, relativeLeft);
Canvas.SetLeft(_activeRectangle, relativeLeft);
+ Canvas.SetTop(_activeRectangle, (_containerCanvas.ActualHeight - _activeRectangle.ActualHeight) / 2);
Canvas.SetLeft(_maxThumb, relativeRight);
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.xaml
index f0c2c5730d6..94902702195 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.xaml
+++ b/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.xaml
@@ -8,36 +8,34 @@
-
+
-
-