質問

私は持っています Style に指定されています Paragraph 私の一部として FlowDocumentReaderのリソースセクション:

<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 そして、それはいくつかあります ParagraphSOとして定義されているs:

<Paragraph Style='{DynamicResource myStyle}">
    Stuff here
</Paragraph>

私が抱えている問題はそれです Foreground テキストには適用されません(LightSteelBlueではなく黒として表示されます)と FontSize のときに変わりません MyFontSize プロパティが変更されます。

背後にあるコードのプロパティ値を確認しましたが、設定されていますが、UIの変更はありません。

これは問題のみであるようです FlowDocument にロードされている場合 FlowDocumentReader 実行時に。 XAMLが明示的に内部に配置されている場合 FlowDocumentReader .xamlファイルで、 Foreground 正しい色であり、 FontSize プロパティ設定に基づいて変更。

アイデア?


解決:

以下の回答で書いたように、移動することによって Style のリソースセクションにブロックします FlowDocument それ自体が問題を解決します。

役に立ちましたか?

解決 2

さて、私はこの問題を解決しました。スタイルブロックをFlowDocumentReaderリソースから、FlowDocument自体のリソースセクションに移動しました。結果のFlowDocumentはそうするように見えます:

<FlowDocument>
   <FlowDocument.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>
   </FlowDocument.Resources>
   <Paragraph Style="{DynamicResource myStyle}">
      Stuff here
   </Paragraph>
</FlowDocument>

他のヒント

段落の前景を直接設定してみましたか?それは、前景の内容を管理する別のPropetity/Attachプロパティでなければなりません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top