本文介绍了WPF C#可拖动拇指的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





感谢您查看我的问题。



我正在尝试做一个可拖动的拇指。



通常我会这样做:



 private void thumb_DragDelta(object sender,DragDeltaEventArgs e)
{
posx + = e.Horizo​​ntalChange;
posy + = e.VerticalChange;
}

public double posx
{
get
{
return Canvas.GetLeft(thumb);
}
设置
{
Canvas.SetLeft(thumb,value);
}
}
public double posy
{
get
{
return Canvas.GetTop(thumb);
}
设置
{
Canvas.SetTop(thumb,value);
}
}





这有效,但我想知道是否有更好的方法(表现明智),也许利用Binding?



谢谢

Medz

解决方案




Hi,

Thanks for having a look at my question.

I am trying to make a dragable thumb.

Normally I do this:

private void thumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            posx += e.HorizontalChange;
            posy += e.VerticalChange;
        }

        public double posx
        {
            get
            {
                return Canvas.GetLeft(thumb);
            }
            set
            {
                Canvas.SetLeft(thumb, value);
            }
        }
        public double posy
        {
            get
            {
                return Canvas.GetTop(thumb);
            }
            set
            {
                Canvas.SetTop(thumb, value);
            }
        }



This works but I was wondering if there was a better way (performance wise), maybe making use of Binding?

Thanks
Medz

解决方案




这篇关于WPF C#可拖动拇指的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 09:26