I am trying to make selected text in a FlowDocument use our custom theme. For other controls, we have used a Style to override the defaults:
<Style.Resources>
...
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="{DynamicResource trimGroundColor}"/>
</Style.Resources>
But this approach does not seem to work with our usage of the FlowDocument. I have tried applying this kind of style to the FlowDocument, the FlowDocumentReader, and several steps along the way using snoop to inspect the visual tree.
Ultimately, the selection UI seems to be drawn by an AdornerLayer inside an AdornerDecorator. I have tried using the style approach above targeting the AdornerDecorator with no success.
We are trying to do this app-wide using default styles.
How do we change this color?
The color can be changed by modifying the FlowDocumentReader.SelectionBrush property:
<Style
TargetType="FlowDocumentReader">
<Setter Property="SelectionBrush"
Value="{DynamicResource trimGroundBrush}"/>
</Style>
Note: In the code sample in the question, we are working with a color resource, while in this solution, we are working with a Brush.