关于silverlight 4中的矩形和画布的两个问题
我在画布上有一个矩形。我已经可以使用鼠标移动该对象,但我找不到如何在运行时使用鼠标调整它的大小? 第二个问题,如何以编程方式检查画布上每个对象(例如矩形)的位置?
I have a rectangle on canvas. I can already moving this object using with mouse, but I can't find how can I resize it in runtime using mouse too?
And second question, how can I programatically check positions of each objects (e.g rectangles) on the canvas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大多数人使用Thumb。 此是一篇 msdn 文章,向您展示如何使用拇指调整大小一块画布。相同的原则可以应用于您的矩形。
Most people use a Thumb. This is an msdn article that shows you how to use a thumb to resize a canvas. The same principles can be applied to your rectangle.
使用鼠标调整矩形大小可能会非常复杂。基本上,您可以侦听鼠标按下、鼠标松开和鼠标移动事件,这将允许您以编程方式调整其宽度和高度。
要在画布内移动矩形,请尝试以下概念:
double x = Canvas.GetLeft(this.myRectangle);
x+=100;
Canvas.SetLeft(this.myRectangle, x);
Re-sizing a rectangle using the mouse can be pretty involved. Basically you can listen for mouse-down, mouse-up, and mouse-move events which would allow you to adjust the width and height of it programmatically.
To move a rectangle within the canvas, try the following concept:
double x = Canvas.GetLeft(this.myRectangle);
x += 100;
Canvas.SetLeft(this.myRectangle, x);