自定义 WPF EndLineCap、StartLineCap 和LineJoin 或新的附加属性
只是想知道是否有人知道我将如何实现附加/自定义 EndLineCap、StartLineCap 和LineJoin 属性?
简而言之,LineJoin="Round" 是我想要的,但我需要角度的两侧都是平滑的 - 而不仅仅是更宽的角度一侧。
另外,我想要的不仅仅是 Rounded EndLineCap 和 StartLineCap,而是在每一端都有一个球(例如,每一端都有一个圆,其直径是线的直径的两倍)。
我也许可以通过附加属性来实现此目的,而不是添加其他自定义项目,但我不知道从哪里开始。
Just wondering if anyone knows how I would implement additional/custom EndLineCap, StartLineCap & LineJoin attributes?
In short, LineJoin="Round" is what I want but I need both sides of the angle are smooth - instead of just the wider angled side.
Also, instead of just Rounded EndLineCap and StartLineCap I want a ball on each end (for instance, a circle at each end who's diameter is double that of the with of the line).
Instead of adding additional custom items, I might be able to achieve this through attached properties, but I don't know where to start.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信可以做你所要求的事情。 Line Caps 在 WPF 中以非常低的级别实现,似乎几乎没有定制的可能性。
WPF 公开的最低级别图形 API 是 DrawingContext< /a>.这提供了诸如 DrawLine 之类的方法采用 Pen 对象来指定 LineCaps 的方式应该绘制。您对 LineCap 的选择仅限于 PenLineCap 中公开的那些 枚举 - 它不提供“自定义”选项。
话虽如此,可以通过修改几何图形中的路径数据来模拟自定义线帽。这个答案可能会给您一些提示。
I don't believe that it is possible to do what you're asking. Line Caps are implemented at a very low level in WPF where there seems to be little possibility of customisation.
The lowest level Graphics API that WPF exposes is the DrawingContext. This provides methods like DrawLine which take a Pen object to specify how LineCaps should be drawn. Your choice of LineCaps is limited to those exposed in the PenLineCap enum - it doesn't provide a "Custom" option.
Having said all that, it may be possible to emulate custom line caps by modifying the path data in a geometry. This answer may give you some hints.