Work with Fast Colored TextBox for Syntax Highlighting in WPF

highlightingsyntax

Is it possible to work with Fast Colored TextBox for Syntax Highlighting in WPF.

http://www.codeproject.com/Articles/161871/Fast-Colored-TextBox-for-syntax-highlighting

I could not find an example that works with WPF c#.

Best Answer

Yes, but you will have to use the WPF component called WindowsFormsHost.

In the code you create an instance of the FastColoredTextBox and add it to the windows forms host object like the example below:

FastColoredTextBox textBox = new FastColoredTextBox();
windowsFormsHost.Child = textBox;

textBox.TextChanged += Ts_TextChanged;
textBox.Text = "public class Hello {  }";