Skip to content

Is there any way to inherit a class from SelectableTextBlock? #17231

Answered by stevemonaco
kuiperzone asked this question in Q&A
Discussion options

You must be logged in to vote

If you check DevTools, the selection is actually being made. Even though SelectableTextBlock is a primitive control that handles its own rendering, it still requires some extra help. The SelectionBrush is null by default unless you set it. So you can either write a new style, set it explicitly, or use StyleKeyOverride so your theme will do the work. eg.

public class AvTextBlock2 : SelectableTextBlock
{
    protected override Type StyleKeyOverride => typeof(SelectableTextBlock);
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kuiperzone
Comment options

Answer selected by kuiperzone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants