unsing ScintillaNet and Syntaxhighlighting with WPF

Aug 26, 2010 at 1:00 PM


i want to create my own texteditor like others too, but i have problems to develop it with WPF.

I know that i have to add the reference of ScintillaNet. I've done this.

  1. But how can i add the Scintilla-control to the window? I don't have a Toolbox like Windows Forms?
  2. How can i highlight my text with Scintilla?

Have any1 any clues or a small Sample?

Thx to all!

Jan 9, 2012 at 8:15 AM


Jan 11, 2012 at 8:22 AM
Edited Jan 11, 2012 at 8:24 AM

After a bit of guddling about (I'm new to WPF) I got this working.  Here are the approximate steps:

Add a reference to ScintillaNet in your assembly references.

ScintillaNet is a Windows Forms control not WPF so you will have to host it in a Windows Form Host.  So put this in your XAML file:

<WindowsFormsHost Name="wfh"></WindowsFormsHost>

Add the ScintillaNet namespace to your XAML file so that you can use objects within it:


In the XAML (because the designer is going to breakpretty quickly plus because it's a windows form control it doesn't seem to show up in the toolbox) add a Scintilla object in between the Windows form host tags so that it is "hosted":

<scintilla:Scintilla Name="CodeBox"></scintilla:Scintilla>

That's you good to go but your designer is probably broken.  As per anytime you use Windows Forms Host objects you need to access it's hosted control using the Child property and cast it to the specific type:

Scintilla scintilla = (Scintilla)wfh.Child.

Hope these steps work for you.  I've had to modify them slightly from how I am actually doing it due to a layer of inheritance I am using.