WPF on Canvas 布局中的锚定/停靠行为
我在 Canvas 布局上相当自由地排列了很多元素,实际上这些元素代表了一个交互式流程图。在应用转换时,我需要对某些元素进行相对转换。
特别是我需要将一些元素锚定或停靠到其父元素。我找到了不同的解决方案,但我不知道它们是否以最优雅的方式解决我的问题。
这是一个例子:
<Line X1="80" X2="800" Y1="730" Y2="730"/>
<Polygon Points="0,30 40,0 40,60" Canvas.Left="48" Canvas.Top="700"/>
多边形绘制了一个三角形,我想让它停靠在线条的左侧。这意味着,当将线平移到新位置或缩小线时,多边形应该随之移动。
这可能吗?
I am arranging quite freely a lot of elements on a Canvas layout, in fact the elements represent an interactive flow-chart. As transformations are applied, I need relative transformations on some of the elements.
Especially I require some elements being anchored or docked to their parent elements. I found different solutions, however I don't know if they solve my problem in the most elegant way.
Here is an example:
<Line X1="80" X2="800" Y1="730" Y2="730"/>
<Polygon Points="0,30 40,0 40,60" Canvas.Left="48" Canvas.Top="700"/>
The Polygon draws a triangle and I would like to let it dock on the left side of line. Which means, when translating the line to a new position or when scaling it down, the Polygon should move with it.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将它们放在自己的画布中,这样您就可以绝对定位外部画布并将内部内容保持在一起。
像这样:
put them in a canvas of their own, that way you can position the outer canvas absolutely and keep the inner stuff together.
like this: