In WPF RichTextBox, does overriding of Underline/Strikethrough work?
Posted
by Daniel Earwicker
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Earwicker
Published on 2010-03-31T14:28:18Z
Indexed on
2010/03/31
18:23 UTC
Read the original article
Hit count: 464
In a WPF RichTextBox
, the effective style of a Run
of text is a result of combining the properties defined on the Run
with the properties it "inherits" from the enclosing Paragraph
and finally the styles on the Document
. So you can set FontWeight
to Bold
at any of those levels. You can also set it Bold
on the Paragraph
and then switch it to Normal
(override it) for a specific Run
.
However, underline and strikethrough are different. They are items that can optionally appear in a list of TextDecorations
, which is a property of Inline
(and hence Run
) and of Paragraph
, but not of Document
. And you can switch on Underline
in the Paragraph
, and it gets inherited so that all Run
s within that Paragraph
default appear underlined by default.
Is it possible to switch it off underline in a specific Run
? i.e. is there a way to insert an entry into the list of TextDecorations
which would mean "Don't underline", thus overriding the Paragraph
's setting?
© Stack Overflow or respective owner