保持 WPF 中相对控件的位置
我有一个 Canvas
,其中有一些用户控件。
您可以将其想象为带有城市点的地图。
假设画布尺寸为 100x100。 假设我只有两个用户控件 A (10, 20) 和 B (50, 50)。
现在,用户将画布大小调整为 1000x1000。
有没有办法使用户控件保持相同的比例:A(100, 200) 和 B(500, 500),而不循环所有控件并将其各个位置更新为手动计算的新位置。
I have a Canvas
in which I have some UserControls.
You can imagine it as a Map with city points.
Say, the canvas size is 100x100.
Say I have only two UserControls A (10, 20) and B (50, 50).
Now, user resizes the canvas to 1000x1000.
Is there a way to keep the UserControls at the same scale: A(100, 200) and B(500, 500) WITHOUT cycle all the controls and updating its individual positions to the manually calculated new ones.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想看看我对这篇文章的回答。如果您有您所在城市的纬度/经度,这是理想的选择。如果没有,听起来您最好编写自己的面板,使用相对坐标而不是绝对坐标。
You might want to take a look at my answer to this post. If you have lat/longs for your cities it's ideal. If not, it sounds like you'd be best writing your own panel that uses relative coordinates rather than absolute.