I need to highlight all occurrences of selected word in AvalonEdit. I created an instance of HihglinghtingRule class:
var rule = new HighlightingRule()
{
Regex = regex, //some regex for finding occurences
Color = new HighlightingColor {Background = new SimpleHighlightingBrush(Colors.Red)}
};
What should I do after it ? Thanks.
To use that
HighlightingRule
, you would have to create another instance of the highlighting engine (HighlightingColorizer
etc.)It's easier and more efficient to write a
DocumentColorizingTransformer
that highlights your word:We have to decide if there is a selection or not:
And here is the
DocumentColorizingTransformer
class: