0

I have been using a RichTextBox to show FlowDocuments in a WPF app, but I found that there is something called FlowDocumentReaderwhich gives me alot of functionality for free. The problem is that while the background in the RichTextBox was shown as white, it is now completely transparent.

I have tried setting the Backgroundproperty, but that only changes the toolbar at the bottom.

<FlowDocumentReader Grid.Row="1" Grid.Column="1" Name="rtbShowDoc" Margin="20, 0" Background="White">
    <FlowDocumentReader.Effect>
        <DropShadowEffect BlurRadius="10" Color="Black" ShadowDepth="3" />
    </FlowDocumentReader.Effect>
</FlowDocumentReader>

Background set

I can do an ugly fix with a DockPanel, but that does not seem like the right way to do it.

<DockPanel Grid.Row="1" Grid.Column="1" Margin="20, 0" Background="White">
    <DockPanel.Effect>
        <DropShadowEffect BlurRadius="10" Color="Black" ShadowDepth="3" />
    </DockPanel.Effect>
    <FlowDocumentReader Grid.Row="1" Grid.Column="1" Name="rtbShowDoc" Background="White">
    </FlowDocumentReader>
</DockPanel>

How can I set the background of a FlowDocumentReader?

EDIT: Added screenshot of running application. As you can see the dropshadow effect is applied to all text inside the FlowDocument. Running application

Tinsa
  • 1,270
  • 12
  • 20
  • That looks like design mode. When you run it and load a FlowDocument is the background not white? – paparazzo Mar 11 '13 at 15:28
  • No, it looks exactly the same. I took a screenshot of design mode to show that it is not my databound `FlowDocument` that somehow affects the style. – Tinsa Mar 12 '13 at 06:10

2 Answers2

2

Try setting the background of the FlowDocument

FlowDocument.Background Property

paparazzo
  • 44,497
  • 23
  • 105
  • 176
  • 1
    Thank you, I used a `Style` to set the `Background` property since my `Flowdocuments` are databound and that worked nicely, not sure why I didn't think of that myself ;) – Tinsa Mar 12 '13 at 13:09
0

In C#:

FlowDocument.Background = Brushes.Red;
Contango
  • 76,540
  • 58
  • 260
  • 305