Colorers - any possible schemas?

SyntaxEditor for WPF Forum

Posted 1 year ago by StockSharp
Version: 22.1.4
Platform: .NET 6.0
Environment: Windows 11 (64-bit)

Tried to see what kind of code colorers can use - . Seems themes and code colorers are different things. Can you please explain - how I can change code highlighting dynamically? Black mode seems to be fully unreadable.

Code for change themes:

ThemeManager.SetTheme(CodeEditor, (string)ThemeSelect.EditValue);

[Modified 1 year ago]

Comments (4)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA


Yes, all Actipro control themes (managed by our ThemeManager) are a completely separate thing from the SyntaxEditor highlighting styles configuration.  This allows you to load any custom SyntaxEditor highlighting style set at any time, which is handy if your app wants to provide several different editor themes to choose from without altering the app theme.  Also of note, highlighting styles only support a single set of colors right now, and our defaults in the syntax languages are intended for light themes.

Please see this documentation topic, since it talks about how to recognize when a ThemeManager theme change occurs in your application, and how to update SyntaxEditor highlighting styles with colors for dark themes.  Our Sample Browser also shows an example of doing this where we load a full set of colors for dark themes.  When you change to a dark theme in our Sample Browser, we use the technique described in the documentation topic to make sure the SyntaxEditor instances render well.

We do recognize that this process could be made easier somehow and that is something we have on the TODO list to look into for the future.

[Modified 1 year ago]

Actipro Software Support

Posted 1 year ago by StockSharp

Maybe you have some code snippet to show how to enable dark mode for SyntaxEditor?

I've put the code on theme change handler:

// Unregister all classification types
var classificationTypes = AmbientHighlightingStyleRegistry.Instance.ClassificationTypes.ToArray();
foreach (var classificationType in classificationTypes)

// Re-register common classification types
new DisplayItemClassificationTypeProvider().RegisterAll();

// NOTE: Possibly load up syntax language instances you use so their various customized styles get registered

and all code highlighting turned off entirely.

[Modified 1 year ago]

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA

Our Sample Browser has complete working code to demonstrate changing to a dark theme, so that's the best source of information. Specifically, there is a SyntaxEditorHelper class with UpdateHighlightingStyleRegistryForThemeChange method you can reference. Here's a link to that method from our open source repository:

Our product installer also has the full source code of that project that you can step through in a debugger for additional insight.  You'll also find a method in the SyntaxEditorHelper class to switch the icon set to one suitable for dark themes.

Actipro Software Support

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA

As promised, we've made this process of switching light/dark themes much easier! The next release of SyntaxEditor will include native support for light/dark themes and without the need for the change handler you previously posted. Please check out our announcement post if you'd like to validate the new functionality in a preview release and provide feedback before it is finalized.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.