8

I am looking for a Silverlight text editor control that provides XML syntax highlighting. I found a few answers in Winforms or WPF, like here on Stackoverflow, but I didn't manage to convert them to Silverlight. The fact that Silverlight is missing System.Drawing is probably a big problem.

The only text editor I found for Silverlight is RichTextEdit on Codeplex, but I don't think it is a suitable base for real-time syntax highlighting.

Has anyone heard of such a control, or can provide hints on how to build one? Many thanks,

Romain

Community
  • 1
  • 1
Romain
  • 2,318
  • 1
  • 23
  • 31

4 Answers4

4

Actipro Software has a syntax highlighter component for Winforms, WPF, and Silverlight:

http://www.actiprosoftware.com/

Chad Brockman
  • 1,176
  • 3
  • 10
  • 19
4

I finally found that control I was looking for! SL2TextBoxWsSynParser

EDIT: This control does not seem to be updated anymore, but a new syntax-highlighting control has surfaced:

It is available here, and used on the CoderProof website.

Romain
  • 2,318
  • 1
  • 23
  • 31
  • 2
    An updated version can be found here: http://www.vladhorby.com/blog/post/2010/11/01/code-editor-control-with-syntax-highlighting-for-silverlight-available.aspx . It now supports various languages (C#, VB.NET, XML, etc) – vladhorby Nov 02 '10 at 16:31
1

I thought this was an interesting question, but you've had no answer.

I don't know of an existing control.

I've built a control to edit XHTML, but it too uses System.Drawing rather than WPF (and therefore isn't for Silverlight).

WPF is probably at least as capable as System.Drawing, but I don't know it.

Hints on how I built it:

  • Define a DOM (a vanilla System.Xml.XmlDocument might suit you)
  • Parse a document to instantiate a DOM
  • Define a user control (with scroll bars)
  • Pass the DOM instance to the user control
  • In the control's 'paint' method, paint the visible fraction of the DOM
  • Implement support for mouse and key presses

If you really want hints on how to build one, ask something more specific.

ChrisW
  • 54,973
  • 13
  • 116
  • 224
0

Hi & thanks for your answer!

Unfortunately, while WPF has drawing capabilities, Silverlight runs a very restricted set of the CLR. Painting the user control looks like quite a difficult task.

However it has been done before with this Rich text editor for Silverlight. I will see if I manage to use similar techniques to render the XML document.

One question though: is the user control fast enough to render the DOM on the fly, as the user makes changes?

Romain
  • 2,318
  • 1
  • 23
  • 31