AvalonEdit Change Syntax Highlighting in Code

Karl_Schuhmann picture Karl_Schuhmann · Apr 23, 2013 · Viewed 11.5k times · Source

I want to change the Syntax Highlighting of AvalonEdit in my Code.

XAML:

 <avalonEdit:TextEditor Name="textEditor" SyntaxHighlighting="{Binding syntaxHighlighting}" />

C#:

public string syntaxHighlighting { get; set; }

public MainWindow()
{
     InitializeComponent();
     syntaxHighlighting = "C#";
     DataContext = this;
}

But the Syntax Highlighting is not changed. What am I doing wrong? Is there a better solution for my problem?

Answer

user2339814 picture user2339814 · Jun 13, 2013
ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#");