SyntaxEditor runtime set/change languages

SyntaxEditor for WPF Forum

Posted 4 years ago by Michael Collins
Version: 18.1.0685
Avatar

Hi, we are trying to reuse control for multiple languages. So depending on document type xml or json, we want to change SyntaxEditor.Document.Language, either with XAML, code behind or VM. 

EditorDocument = new EditorDocument() { Language = new JsonSyntaxLanguage() }; compliles, thou not sure if that will work

but 

EditorDocument = new EditorDocument() { Language = new XmlSyntaxLanguage() }; fails to compile complaining XmlSyntaxLanguage is not of type ISyntaxLanguage.

We want to set language on load depending on document type. Please let me know how do I set language runtime. Or is there some other method to achive this.

Thanks.

Comments (1)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Michael,

That's odd, there must be something else going on here in your project since XmlSyntaxLanguage definitely is an ISyntaxLanguage.  You can see we pass a XmlSyntaxLanguage in our main demo to a method that requires ISyntaxLanguage:

this.LoadLanguage(new ActiproSoftware.Text.Languages.Xml.Implementation.XmlSyntaxLanguage());

I'd take a look (F12 in VS) at the type being returned by your XmlSyntaxLanguage constructor.  Are you positive it's an Actipro ISyntaxLanguage and not some custom class you might have defined with the same name?  If so, perhaps you are referencing two different builds of our control .dlls in your project?  If that is the case, then I could see this error popping up.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.