@@ -23,64 +23,62 @@ public static readonly DependencyProperty OnlyShowFocusVisualWhileDraggingProper
2323 typeof ( SliderAssist ) ,
2424 new PropertyMetadata ( false ) ) ;
2525
26- public static void SetOnlyShowFocusVisualWhileDragging ( RangeBase element , bool value )
27- => element . SetValue ( OnlyShowFocusVisualWhileDraggingProperty , value ) ;
28-
2926 public static bool GetOnlyShowFocusVisualWhileDragging ( RangeBase element )
3027 => ( bool ) element . GetValue ( OnlyShowFocusVisualWhileDraggingProperty ) ;
3128
29+ public static void SetOnlyShowFocusVisualWhileDragging ( RangeBase element , bool value )
30+ => element . SetValue ( OnlyShowFocusVisualWhileDraggingProperty , value ) ;
31+
3232 public static readonly DependencyProperty ToolTipFormatProperty
3333 = DependencyProperty . RegisterAttached (
3434 "ToolTipFormat" ,
3535 typeof ( string ) ,
3636 typeof ( SliderAssist ) ,
3737 new PropertyMetadata ( null ) ) ;
3838
39- public static void SetToolTipFormat ( RangeBase element , string value )
40- => element . SetValue ( ToolTipFormatProperty , value ) ;
41-
4239 public static string GetToolTipFormat ( RangeBase element )
4340 => ( string ) element . GetValue ( ToolTipFormatProperty ) ;
4441
45- #region Issue3628
46- internal static readonly DependencyProperty FocusParentSliderOnClickProperty =
42+ public static void SetToolTipFormat ( RangeBase element , string value )
43+ => element . SetValue ( ToolTipFormatProperty , value ) ;
44+
45+ // Fix for Issue3628
46+ public static readonly DependencyProperty FocusSliderOnClickProperty =
4747 DependencyProperty . RegisterAttached (
48- "FocusParentSliderOnClick " ,
48+ "FocusSliderOnClick " ,
4949 typeof ( bool ) ,
5050 typeof ( SliderAssist ) ,
51- new PropertyMetadata ( false , OnFocusParentSliderOnClickChanged ) ) ;
51+ new PropertyMetadata ( false , OnFocusSliderOnClickChanged ) ) ;
5252
53- internal static bool GetFocusParentSliderOnClick ( DependencyObject obj ) =>
54- ( bool ) obj . GetValue ( FocusParentSliderOnClickProperty ) ;
53+ public static bool GetFocusSliderOnClick ( RangeBase obj ) =>
54+ ( bool ) obj . GetValue ( FocusSliderOnClickProperty ) ;
5555
56- internal static void SetFocusParentSliderOnClick ( DependencyObject obj , bool value ) =>
57- obj . SetValue ( FocusParentSliderOnClickProperty , value ) ;
56+ public static void SetFocusSliderOnClick ( RangeBase obj , bool value ) =>
57+ obj . SetValue ( FocusSliderOnClickProperty , value ) ;
5858
59- private static void OnFocusParentSliderOnClickChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
59+ private static void OnFocusSliderOnClickChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
6060 {
61- if ( d is RepeatButton repeatButton )
61+ if ( d is Slider slider )
6262 {
6363 if ( ( bool ) e . NewValue )
6464 {
65- repeatButton . AddHandler ( UIElement . PreviewMouseLeftButtonDownEvent ,
66- ( MouseButtonEventHandler ) RepeatButton_PreviewMouseLeftButtonDown ,
65+ slider . AddHandler ( UIElement . PreviewMouseLeftButtonDownEvent ,
66+ ( MouseButtonEventHandler ) Slider_PreviewMouseLeftButtonDown ,
6767 true ) ;
6868 }
6969 else
7070 {
71- repeatButton . RemoveHandler ( UIElement . PreviewMouseLeftButtonDownEvent ,
72- ( MouseButtonEventHandler ) RepeatButton_PreviewMouseLeftButtonDown ) ;
71+ slider . RemoveHandler ( UIElement . PreviewMouseLeftButtonDownEvent ,
72+ ( MouseButtonEventHandler ) Slider_PreviewMouseLeftButtonDown ) ;
7373 }
7474 }
7575 }
7676
77- private static void RepeatButton_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
77+ private static void Slider_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
7878 {
79- if ( sender is DependencyObject repeatButton )
79+ if ( sender is Slider slider )
8080 {
81- var slider = TreeHelper . FindParent < Slider > ( repeatButton ) ;
82- slider ? . Focus ( ) ;
81+ slider . Focus ( ) ;
8382 }
8483 }
85- #endregion
8684}
0 commit comments