dotnet / dotnet/wpf

Highlight annotations and sticky note annotations on FlowDocument use hard coded colors

Open
#1,517 0 comments 0 reactions 0 assignees View on GitHub
Accessibility Bug
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.

![sticky note annotation issue](https://user-images.githubusercontent.com/14054078/62409726-95f37c80-b5d3-11e9-8da0-828e6a0b17a3.PNG)

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.