Hi,
is there a way to Highlight a single Token in the XamSyntaxEditor?
I have to perform a Min- Max-Limit check for a Token where the Limits are only known after starting the Program. Thus I am looking for a way to find all Tokens I need to check and Highlight them (overriding the Language style) if they are out of bounds.
The best would be if I could somehow use the Syntaxerror reporting.
Thus far I was able to find the Tokens and check the values, but I don't know how to Highlight them to show the User that he has entered a not valid value.
Regards
Thomas Stüven
Hello Thomas,
There currently does not exist a way to highlight a single token in the XamSyntaxEditor control that I am personally aware of. I am currently checking with our senior development staff to be certain, but I believe that the text placed in the editor pulls its color purely from the Language style supported by the ClassificationAppearanceMap in this case.
While I don't entirely understand your scenario in this case, I have to wonder if a XamSyntaxEditor is really your best bet here, or whether you would want something more along the lines of a XamRichTextEditor, as this would allow you to highlight a particular "node." You can read further about the XamRichTextEditor at the following online documentation article: https://es.infragistics.com/help/wpf/xamrichtexteditor.
If you would like to see single-node highlighting added to the XamSyntaxEditor control, I would recommend suggesting a new product idea for this feature at http://ideas.infragistics.com. This product ideas site places you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew,
thank you for the quick response.
I'm using the XamSyntaxEditor because we need the Syntax Highlighting. For this I use a custom Language build from an EBNF File.
Also I don't want to set the Highlight for the Token directly in the Editor as that would break the MVVM Pattern. I actually trying to do that thru the TextDocument in the ViewModel. I'm sorry for not being clear enough on this.
SincerelyThomas
Hi again,
I finally worked something out that works for me. I don't know how I could miss this document before: https://es.infragistics.com/help/wpf/ig-spe-custom-diagnostics-and-annotations
Well I think I can make that work. Thank you once again for your help.
Kind RegardsThomas Stüven
Hi Andrew.
thanks again for the quick reply.
I will consider making a feature request thru the ideas platform.
I just wonder if and how others do and visualize these kind of semantic checks.
Kind regardsThomas Stüven
I have been speaking with our development staff on this matter, and highlighting a single Token from the TextDocument or the actual XamSyntaxEditor does not appear to be a supported scenario. The color of the text in the editor is currently mapped by the assigned ClassificationAppearanceMap to the editor, and this all happens internal to the XamSyntaxEditor control. The different ClassificationAppearanceMap elements can take different TextDocumentAppearance objects, and these are based on the grammar that is set up for a particular language. Based on that grammar, the XamSyntaxEditor looks at the text being written, and assigns the corresponding TextDocumentAppearance to it if it falls as one of the different ClassificationAppearanceMap entries.
If you would like to see the ability to highlight a particular token in the XamSyntaxEditor via either the editor or its document, I would again recommend suggesting a new product idea for this functionality at http://ideas.infragistics.com.