Home > Enterprise >  How to add a right margin to AvalonEdit number line?
How to add a right margin to AvalonEdit number line?

Time:04-16

I'm using AvalonEdit WPF control with a .Net Framework 4.8 project, using Visual Studio 2019 under Windows 10 64bit.

I need to add a right margin to the linenumbers. To understand what i need i attach a selfexplanatory image:

enter image description here

My actual xaml code is next:

<avalonEdit:TextEditor
    Grid.Column="2" Grid.Row="2"
    xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
    xmlns:editing="clr-namespace:ICSharpCode.AvalonEdit.Editing;assembly=ICSharpCode.AvalonEdit"
    xmlns:rendering="clr-namespace:ICSharpCode.AvalonEdit.Rendering;assembly=ICSharpCode.AvalonEdit"
    Name="TextEditor"
    FontFamily="Consolas"
    SyntaxHighlighting="C#"
    ShowLineNumbers="True"
    FontSize="10pt" Margin="0">
</avalonEdit:TextEditor>

Hope that someone can give me a hand on this, i spend two days trying to add this margin but couldn't achieve a proper solution. Thanks in advance.

CodePudding user response:

While the approach in my comment will work, I thought of an even easier way. Just copy the style for TextArea from the source and modify it to include some margin on the right of the ItemsControl that contains all the editor's margins. The style is here:

enter image description here

  • Related