在路径上添加图像 [英] Adding Image on Paths

查看:88
本文介绍了在路径上添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我有绘制城市的路径,我想将图像放置在这些城市中,而我不能将图像放置在<Path>标签中.

My problem is I have paths to draw cities and I want to put images inside these cities I cant put Image inside <Path> tags.

为什么我不能编写这样的代码?有什么解决办法吗?

Why cant I write such code? any solution?

推荐答案

使用具有x,y位置的画布或自定义面板,并将图像添加到正确的坐标(路径使用相同的坐标).

Use a canvas or a custom panel with x,y placements and add images to the correct coordinates (same coordinates used by path).

如果您不知道路径节点,可以查询路径节点.

You can query the path nodes to find their coordinates if you don't know them.

由于窗口大小会发生变化并相应地协调拉伸",因此需要实现自定义面板. -从Panel继承并覆盖此示例中的度量和排列方法: http://www.wpftutorial.net/CustomLayoutPanel.html

Since your window size changes and coordinates "stretch" accordingly, you will need to implement a custom panel. - Inherit from Panel and override measure and arrange methods as in this example: http://www.wpftutorial.net/CustomLayoutPanel.html

您的自定义面板应该具有附加的X和Y依赖属性(如Canvas一样),只有方法应使用相对坐标(0到1)而不是(0到宽度和0到高度)或除以原始路径的宽度和高度以归一化为坐标.

Your custom panel should have X and Y attached dependency properties (like Canvas does) only that methods should use either relative coordinates (0 to 1) instead of (0 to width and 0 to height) or divide by original path width and height to normalize to coordinates.

这篇关于在路径上添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆