Highlight annotations and sticky note annotations on FlowDocument use hard coded colors
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
When highlight annotations or sticky note annotations are made to a FlowDocument, the highlight (and anchor) use hard coded colors. This behavior is undesirable as it can lead to accessibility problems when using custom themes.

The sticky note highlight annotation uses hard coded colors defined here:
[MarkedHighlightComponent.cs
](https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Component/MarkedHighlightComponent.cs#L1143)
```csharp
internal static Color DefaultAnchorBackground = (Color)ColorConverter.ConvertFromString("#3380FF80");
internal static Color DefaultMarkerColor = (Color)ColorConverter.ConvertFromString("#FF008000");
internal static Color DefaultActiveAnchorBackground = (Color)ColorConverter.ConvertFromString("#3300FF00");
internal static Color DefaultActiveMarkerColor = (Color)ColorConverter.ConvertFromString("#FF008000");
```
The highlight annotation uses hard coded colors defined here:
[HighlightComponent.cs](https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Component/HighlightComponent.cs#L680)
```csharp
private Color _defaultBackroundColor = (Color)ColorConverter.ConvertFromString("#33FFFF00");
private Color _defaultActiveBackgroundColor = (Color)ColorConverter.ConvertFromString("#339ACD32");
```
It ought to be possible to set these colors from the controls which support annotations i.e. FlowDocumentReader and FlowDocumentScrollViewer which derive from DocumentViewerBase.
Currently the only way to alter the highlight color is to manually modify the AnnotationResource objects in the Annotation.Cargos each time an annotation is loaded or when the application or system theme changes. The anchor colors can only be set via reflection.
Contributor guide
Assessment
This issue has not been assessed yet.