保持 WPF 中相对控件的位置

发布于 2024-10-04 14:50:21 字数 243 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福%小乖 2024-10-11 14:50:21

您可能想看看我对这篇文章的回答。如果您有您所在城市的纬度/经度,这是理想的选择。如果没有,听起来您最好编写自己的面板,使用相对坐标而不是绝对坐标。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文