简体   繁体   中英

How can I change the size of two rectangles in a canvas by moving an ellipse?

I have a canvas with two rectangles in it, side by side. I want to have an ellipse over where they meet that I can drag horizontally and have the rectangles change size to always meet under this movable elipse, just like a slider, but with shapes. I've read this

http://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part-1 , snapshot as below: 在此处输入图片说明

and so far I have a clickable, moving ellipse and two rectangles beneath it. How do I pass the changing horizontal position of the ellipse to the two rectangles so that they can resize?

Any help appreciated, C# just seems like magic to me.

Not sure if all you want is to get the location of the ellipse, if yes try below snippet

var left=Canvas.GetLeft(ellipse1);
var top=Canvas.GetTop(ellipse1);

To set its location and size:

Canvas.SetLeft(ellipse1, left+100);
ellipse1.ActualWidth= ...;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM