WPF:如何设置折线的偏移
我有 3 条具有相同几何形状的折线。
我想设置其中两个的偏移量,这样它们就会出现在彼此旁边。
我怎样才能做到这一点?
谢谢。
I have 3 PolyLines that have same geometry.
I would like to set offset to two of them, so they would appear right next to each other.
How can i do that?
thanx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于您使用的容器。如果您使用网格(没有行或列)或画布,它们会直接位于彼此之上。您可以通过边距(网格)或左/上(画布)将它们分开。
或者使用不同的面板,例如 Stackpanel,它会自动将它们排列在一起。
编辑:
在评论中,我们提出了使用 LinearGradientBrush 为单个几何体着色的想法,如下所示:
That depends on the container you are using. If you use Grid (with no rows or colums) or canvas, they are directly on top of each other. You can space them apart by means of Margin (grid) or Left/Top (canvas).
Or use a different Panel, like Stackpanel, that arranges them next to each other automatically.
Edit:
In the comments, we developed the idea of using a LinearGradientBrush to color a single Geometry, like this:
我想我理解您的确切需求:您希望像在路线图上一样绘制折线,其中多条线遵循相同的路径,但它们之间始终保持相同的距离。
这是一个更加复杂的问题。 Key Johnson 有一篇出色的文章,其中他创建了几何视觉画笔:Stacked Geometry Brush Factory< /a>.
他设法做到的一个例子:
I think I understood your exact need: you wish to draw polylines like on a road map, where multiple lines follow the same path but always keep the same distance between them.
This is a much more complicated problem. There is an excellent article by Key Johnson where he creates geometric visual brushes: Stacked Geometry Brush Factory.
An example of what he manages to do: