Is there a way to apply an underline text decoration to one character only in a TextBlock (or any amount less than the full block)?
I have some text that I want output as "this worf is misspelt" and have the f
in worf
underlined.
I know you can do:
TextBlock47.TextDecorations = TextDecorations.Underline;
but I don't want the entire block underlined.
Failing that, is there another control I can use other than TextBlock that gives this capability? I've looked into rich text but that seems like an awful lot of work for what's a simple effect. If that is the only way, how do I go about generating text of a specific format (10pt, Courier New, one character underlined) in c# code?
TextBlock is not editable.
textBlock. Inlines. Add(new Run(Boldsplist) { FontWeight = FontWeights. Bold }); this.
HTML <u> Tag. The <u> tag in HTML stands for underline, and it's used to underline the text enclosed within the <u> tag. This tag is generally used to underline misspelled words.
textblock (plural textblocks) The block of pages making up a book, excluding the binding.
You can use Underline in a TextBlock:
<TextBlock Name="textBlock47">
this wor<Underline>f</Underline> is misspelt
</TextBlock>
or
textBlock47.Inlines.Add(new Run("this wor"));
textBlock47.Inlines.Add(new Underline(new Run("f")));
textBlock47.Inlines.Add(new Run(" is misspelt"));
Did you look at the Run tag?
http://www.codeproject.com/Tips/60784/WPF-RichTextBox-features-in-TextBlock.aspx
http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With