我有一個指定Paragraph
Style
爲我FlowDocumentReader
的資源部分的一部分:WPF樣式並不影響某些屬性
<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>
我有一個的.xaml文件,其中包含我的FlowDocument
它有一些Paragraph
S的被定義爲這樣:
<Paragraph Style='{DynamicResource myStyle}">
Stuff here
</Paragraph>
,我有是Foreground
並不適用於文本的問題(它顯示爲黑色,而不是淺鋼)和當修改MyFontSize
屬性時,不會更改。
我已檢查後面的代碼中的屬性值,它已設置,但它不會導致UI中的更改。
如果在運行時將其加載到FlowDocumentReader
,這似乎只是FlowDocument
的一個問題。如果XAML明確放在FlowDocumentReader
內的文件名爲.xaml的Foreground
是正確的顏色,並基於該屬性設置FontSize
變化。
想法?
解決:
正如我在我的回答如下寫道,由Style
塊移動到FlowDocument
自身解決問題的資源部分。
是的,如果我設置paragraph.Foreground =新的SolidColorBrush(Colors.Red),它會改變顏色。 – itsmatt