you can do something like this, since there is no drag event for the thumb you can call the mouse_enter event from code behind and use an ICommand to fetch the value of the slider when the thumb is slided over, the code looks something like this
private System.Windows.Controls.Primitives.Thumb _thumb;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (_thumb != null)
{
_thumb.MouseEnter -= new MouseEventHandler(thumb_MouseEnter);
}
if (_thumb == null)
{
System.Windows.Controls.Primitives.Track track = this.Template.FindName(
"PART_Track", this) as System.Windows.Controls.Primitives.Track;
if (track != null)
_thumb = track.Thumb;
}
if (_thumb != null)
{
_thumb.MouseEnter += thumb_MouseEnter;
}
}
void thumb_MouseEnter(object sender, MouseEventArgs e)
{
if (!this.IsMoveToPointEnabled)
return;
if (e.LeftButton == MouseButtonState.Pressed)
{
var args = new MouseButtonEventArgs(
e.MouseDevice, e.Timestamp, MouseButton.Left);
args.RoutedEvent = MouseLeftButtonDownEvent;
(sender as System.Windows.Controls.Primitives.Thumb).RaiseEvent(args);
}
}
public static readonly RoutedEvent CommandChangedEvent = EventManager.RegisterRoutedEvent(
"CommandChangedEvent",
RoutingStrategy.Bubble,
typeof(RoutedPropertyChangedEventHandler<icommand>),
typeof(XSlider));
public event RoutedPropertyChangedEventHandler<icommand> CommandChanged
{
add { AddHandler(CommandChangedEvent, value); }
remove { RemoveHandler(CommandChangedEvent, value); }
}
protected virtual void OnCommandChanged(ICommand oldValue, ICommand newValue)
{
RoutedPropertyChangedEventArgs<icommand> args = new RoutedPropertyChangedEventArgs<icommand>(oldValue, newValue);
args.RoutedEvent = XSlider.CommandChangedEvent;
RaiseEvent(args);
if (cmd_CanExecuteChangedHandler == null)
cmd_CanExecuteChangedHandler = cmd_CanExecuteChanged;
if (oldValue != null)
oldValue.CanExecuteChanged -= cmd_CanExecuteChangedHandler;
if (newValue != null)
newValue.CanExecuteChanged += cmd_CanExecuteChangedHandler;
else
cmd_CanExecuteChangedHandler = null;
UpdateCanExecute();
}
EventHandler cmd_CanExecuteChangedHandler;
void cmd_CanExecuteChanged(object sender, EventArgs e)
{
UpdateCanExecute();
}
void UpdateCanExecute()
{
if (IsCommandExecuting)
return;
ICommand cmd = Command;
if (cmd == null)
{
IsEnabled = true;
}
else
{
try
{
IsCommandExecuting = true;
var ca = new CommandCanExecuteParameter(CommandParameter);
bool enabled = CommandUtil.CanExecute(this, CommandParameter);
IsEnabled = enabled;
CommandUtil.CanExecute(this, ca);
if (enabled && ca.CurrentValue != null)
{
if (ca.CurrentValue is float)
{
Value = (float)ca.CurrentValue;
}
else if (ca.CurrentValue is double)
{
Value = (double)ca.CurrentValue;
}
if (ca.CurrentValue is RangedValue)
{
var rangedValue = (RangedValue)ca.CurrentValue;
Value = rangedValue.Value;
if (rangedValue.Minimum.HasValue)
Minimum = rangedValue.Minimum.Value;
if (rangedValue.Maximum.HasValue)
Maximum = rangedValue.Maximum.Value;
}
}
}
finally { IsCommandExecuting = false; }
}
}
private bool IsCommandExecuting { get; set; }
Note: Pls make changes according to the variable names used in your class
Hope this helps!!