我正在开发一个模拟时钟选择器控件。用户可以单击分针或时针并拖动以转动指针以选择特定时间。我想知道如何检测这样的点击和拖动事件。
我尝试使用 MouseLeftButtonDown + MouseMove 但我无法让它工作,因为尽管我使用了标志,但当 mousemove 发生时总是触发 MouseMove。有没有更简单的方法?
public bool dragAction = false;
private void minuteHand_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
dragAction = true;
minuteHand_MouseMove(this.minuteHand, e);
}
private void minuteHand_MouseMove(object sender, MouseEventArgs e)
{
if (dragAction == true)
{
//my code: moving the needle
}
}
private void minuteHand_MouseLeftButtonUp(object sender, MouseEventArgs e)
{
dragAction = false;
}