pax*_*blo 5 c# wpf textblock underline
有没有办法只在TextBlock(或任何小于整个块的数量)中对一个字符应用下划线文本修饰?
我有一些文字,我想输出"这是WORF名称拼写",并有f在worf下划线.
我知道你可以这样做:
TextBlock47.TextDecorations = TextDecorations.Underline;
Run Code Online (Sandbox Code Playgroud)
但我不希望整个区块加下划线.
如果失败了,除了TextBlock之外还有其他控件可以使用它来提供这种功能吗?我已经研究过富文本,但对于一个简单的效果来说,这似乎是一项非常重要的工作.如果这是唯一的方法,我如何在c#代码中生成特定格式的文本(10pt,Courier New,带下划线的一个字符)?
dtb*_*dtb 18
您可以在TextBlock中使用下划线:
<TextBlock Name="textBlock47">
this wor<Underline>f</Underline> is misspelt
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
要么
textBlock47.Inlines.Add(new Run("this wor"));
textBlock47.Inlines.Add(new Underline(new Run("f")));
textBlock47.Inlines.Add(new Run(" is misspelt"));
Run Code Online (Sandbox Code Playgroud)