Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: TextLayer is rendered behind SelectionLayer #342

Merged

Conversation

mgarstenauer
Copy link
Contributor

Problem:
The TextLayer is rendered behind the SelectionLayer, which makes the text hard to read when selected. If you style the control and set an opaque SelectionBrush then the text is obscured completely.

Cause:
The problem is that TextView.Layers and TextView.VisualChildren are out of sync:
The Layers are

  1. SelectionLayer
  2. TextLayer
  3. CaretLayer

but the VisualChildren are

  1. TextLayer
  2. SelectionLayer
  3. CaretLayer

Fix:
The LayerCollection needs to insert the control at the correct index. (The first n visual children should correspond to the n layers in the LayerCollection.)

danipen

This comment was marked as off-topic.

Copy link
Collaborator

@danipen danipen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Gillibald Gillibald merged commit e3c7751 into AvaloniaUI:master Jun 9, 2023
@mgarstenauer mgarstenauer deleted the fix-textlayer-behind-selectionlayer branch June 9, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants