Reputation: 132
How can I for example change the font only for line 15 ? I've used .ScrollTo(15,4);
but there is no command to highlight or anything when I'm at line 15.(I want to do this by code dynamically). So are there any ways to edit just one line ? And also I would like to know how can I highlight that line by code.
Here is my xaml:
<Grid>
<avalonEdit:TextEditor
Name="debuggertext"
FontFamily="Consolas"
FontSize="10pt"
ShowLineNumbers="True"
SyntaxHighlighting="C++" VerticalScrollBarVisibility="Auto" IsReadOnly="True" HorizontalScrollBarVisibility="Disabled"
/>
Upvotes: 0
Views: 1214
Reputation: 16464
AvalonEdit is a code editor; not a rich text editor. You cannot just change the color of some piece of text because AvalonEdit does not store colors, it computes them on-the-fly.
The solution is to store the colors yourself, and extend AvalonEdit's on-the-fly formatting to read from your data structure. Read the draft of the 'Rendering' section of my Code Project article (most of that section didn't make it into the final article as the article was intended as an introduction to AvalonEdit); and then take a look at this forum post for some ideas.
AvalonEdit 5.0 also adds some classes that can help with implementing a rich text editor: ICSharpCode.AvalonEdit.Highlighting.RichTextModel
is a data structure that can store font style/weight/color; RichTextColorizer
can apply these during rendering. Note that you'll manually have to hook these classes up to the editor.
Upvotes: 2