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:
http://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part-1,快照如下:
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.
任何帮助都值得感激,c#对我来说就像魔术。
1 个解决方案
#1
0
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= ...;
#1
0
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= ...;