当把Slider的IsMoveToPointEnabled设置为True之后, 鼠标点哪里Thumb就跳到哪里, 但是如果继续移动鼠标, Thumb就不会跟随鼠标动了
先添加下面的方法
private void thumb_MouseEnter(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && e.MouseDevice.Captured == null)
{
MouseButtonEventArgs args = new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, MouseButton.Left);
args.RoutedEvent = MouseLeftButtonDownEvent;
(sender as Thumb).RaiseEvent(args);
}
}
窗口初始化以后执行:
Slider1.ApplyTemplate();
(Slider1.Template.FindName("PART_Track", Slider1) as Track).Thumb.MouseEnter += new MouseEventHandler(thumb_MouseEnter);
但是发现如果Slider在Popup中的话这样无效