开发者

two questions about rectangle and canvas in silverlight 4

开发者 https://www.devze.com 2023-01-21 01:58 出处:网络
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?

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) 开发者_Go百科on the canvas?


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.


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);

0

精彩评论

暂无评论...
验证码 换一张
取 消