Romain
Romain

Reputation: 2348

Silverlight XML editor / syntax highlighting

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

Upvotes: 8

Views: 8232

Answers (4)

Chad Brockman
Chad Brockman

Reputation: 1426

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

http://www.actiprosoftware.com/

Upvotes: 4

Romain
Romain

Reputation: 2348

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.

Upvotes: 4

Romain
Romain

Reputation: 2348

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?

Upvotes: 0

ChrisW
ChrisW

Reputation: 56123

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.

Upvotes: 1

Related Questions