FlowDocument 中的波浪下划线
在 WPF 中,是否有一种简单的方法可以向 FlowDocument
元素添加波浪下划线(如 Word 中的拼写错误)? 有 Underline
类,但似乎没有办法设置它的样式。
In WPF, is there an easy way to add wavy underlines (like spelling errors in Word) to FlowDocument
elements? There's the Underline
class, but there seems to be no way to style it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用对 Robert Macne 的解决方案进行以下更改来创建波浪效果
将视觉画笔添加到 Grid.Resources 部分:
并将笔更改为:
You can create the wavy effect using the following changes to Robert Macne's solution
Add a visual brush to the Grid.Resources section:
And change the pen to:
红色下划线很简单:
波浪形红色下划线会涉及更多一些,但我认为您可以创建一个带有波浪形红色东西的 VisualBrush,并将其设置为笔的画笔您为下划线 TextDecoration 指定的。 编辑:请参阅 bstoney 的帖子。
A red underline is simple enough:
A wavy red underline would be a bit more involved, but I think you could create a VisualBrush with a wavy red thing in it, and set that as the Brush of the Pen that you specify for the underlining TextDecoration. Edit: see bstoney's post for this.
这是@bstoney 在代码中实现的解决方案。
Here is @bstoney's solution implemented in code.
另一种方法可以是:创建一个带有两条线(类似倒V)的绘图组,并将该绘图组作为绘图画笔的内容传递,并使用平铺作为模式,以便它可以重复。 但当我们画两条线时,这里的峰值将被指出,一条线从另一条线的末端开始。
示例如下:
Another way can be : Creating a drawing group with two lines(kind of inverted V) and passing that drawing group as content for drawing brush and having Tile as mode so that it can repeat. But here peaks will be pointed as we are drawing two lines, one starts from others end.
Sample will look like :
我知道这是一个老问题,但我更喜欢这把刷子。 它有点棱角,但非常干净。
I know this is an old question but I prefer this brush. It's a little angular but very clean.