Reputation: 34810
I'd like to use the RichTextBox
to display some rich text but make it disabled, so the text can't be edited. I want the background to be transparent while it's disabled, but the default behavior is to make the background greyed when the control is disabled. I've experimented with overriding the ControlTemplate
and Styles but no luck.
Setting the background to transparent works great as long as I don't set IsEnabled="False"
. There is a style trigger in the base ControlTemplate
that resets the background when the control is disabled, but I can't figure out how to override it.
Upvotes: 2
Views: 2535
Reputation: 6269
you can just set the Background property of the RichTextBox transparent.
<Grid>
<Image Source="Resources/nelson.png" />
<RichTextBox Background="Transparent" IsReadOnly="True">
<FlowDocument>
<Paragraph>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et
ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</Paragraph>
</FlowDocument>
</RichTextBox>
</Grid>
Upvotes: 2
Reputation: 2295
<RichTextBox Background="Transparent" IsReadOnly="True">
Works as well as
this.richTextBox1.IsReadOnly = "true";
You do not need to use the IsEnabled property, as the IsReadOnly does not allow the user to interact, which is what you where looking for right?
Upvotes: 4