EditIndicator does not change colors when changing the theme

SyntaxEditor for WPF Forum

Posted 2 years ago by Daniel Constantin - ModuleWorks GmbH
Version: 19.1.0687
Avatar

Hi,

When I am switching between dark and light theme the EditIndicator does not change the background color to dark one.

The default theme is light and also the caret indicator is still black on dark theme. In the sample browser is white.

I use these dll's:

ActiproSoftware.Shared.Wpf.dll

ActiproSoftware.SyntaxEditor.Wpf.dll

ActiproSoftware.Text.Wpf.dll

ActiproSoftware.Themes.Luna.Wpf.dll

ActiproSoftware.Themes.Office.Wpf.dll

Kind regards,

Daniel

Comments (7)

Posted 2 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

I tried also this code from the documentation

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

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

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

but does not work.

Kind regards,

Danil

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

Hi Daniel,

The caret brush comes from the SyntaxEditor.CaretBrush property.  If that is null, it will use Black or White, depending on the current editor background lightness that it detects.

By default, SyntaxEditor binds its CaretBrush property to the value of the themes:AssetResourceKeys.EditCaretBackgroundNormalBrushKey theme resource.  That theme resource value will come from our Actipro themes.

But if you mean you are only loading a SyntaxEditor dark theme while still in a light Actipro app theme, then the scenario you describe could occur.  In that case, you might want to either set CaretBrush to null or to an appropriate Brush for your SyntaxEditor theme.


Actipro Software Support

Posted 2 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

This line breaks my coloring:

_ = new DisplayItemClassificationTypeProvider().RegisterAll();

If I remove this line the Indicator Margin will be colored correctly when changing themes.

The thing is I need to register the classification types.

I have only one Theme inside the entire application. I do not use separate themes for the controls.

[Modified 2 years ago]

Posted 2 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

I also sent a sample on the 'support@actiprosoftware.com'.

Kind regards,

Daniel

Posted 2 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

One more mention. I change the Document.Language in runtime. The user can change the editor language in runtime :)

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

Thank you for the sample, that helps a lot.  I think the problem is that you are changing the app theme to dark and that will make the control's Foreground (which ends up being the "plain text" foreground color) and Background (the text area background) go to dark theme colors.  But everything else in the editor, like the indicator margin, modification marks, syntax highlighting is still geared for a light theme.  That's why the indicator margin is still in a lighter color, and the modification mark is too bright.

What you're missing is logic like in our sample's UpdateHighlightingStyleRegistryForThemeChange method.  That will try and update all the display item and other syntax highlighting styles for dark when a dark app theme is loaded.  Please check that out.

Also we know that the updating of SyntaxEditor control theme for app theme changes is tedious right now, and we have a TODO item to work on improving and streamlining that process.


Actipro Software Support

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

Hi Daniel,

The next release of SyntaxEditor will include native support for light/dark themes tied directly to the application theme by default. 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 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.