I've got a Style
specified for Paragraph
as part of my FlowDocumentReader
's Resources section:
<FlowDocumentReader>
<FlowDocumentReader.Resources>
<Style x:Key="myStyle" TargetType="{x:Type Paragraph}">
<Setter Property="Foreground" Value="LightSteelBlue" />
<Setter Property="BorderBrush" Value="LightSteelBlue" />
<Setter Property="BorderThickness" Value="1.0" />
<Setter Property="FontStyle" Value="Italic" />
<Setter Property="FontSize" Value="{Binding Path=MyFontSize}" />
</Style>
</FlowDocumentReader.Resources>
</FlowDocumentReader>
I've got a .xaml file which contains my FlowDocument
and it has some Paragraph
s which are defined as so:
<Paragraph Style='{DynamicResource myStyle}">
Stuff here
</Paragraph>
The problem that I have is that Foreground
doesn't apply to the text (it shows as Black rather than LightSteelBlue) and the FontSize
does not change when the MyFontSize
property is modified.
I've checked the property value in the code behind and it is set but it doesn't result in a change in the UI.
This seems to only be an issue with the FlowDocument
if it is loaded into the FlowDocumentReader
at runtime. If the XAML is explicitly placed inside the FlowDocumentReader
in the .xaml file, the Foreground
is the correct color and the FontSize
changes based on the property setting.
Ideas?
Solved:
As I wrote in my answer below, by moving the Style
block into the Resources section of the FlowDocument
itself resolves the issue.