WPF SyntaxEditor in ElementHost fails to change scrollbar theme

SyntaxEditor for WPF Forum

Posted 6 years ago by (Anonymous)
Version: 18.1.0673
Platform: .NET 4.7
Environment: Windows 10 (64-bit)

If you create a WPF app and add a WPF SyntaxEditor control, it sets the colours as per the current theme as expected.

However, if you create a WinForms app and add a WPF SyntaxEditor as the child of the ElementHost control, all theme aspects are correct appart from the scrollbars.

  1. Create a WinForms application called 'WindowsFormsApp1' and references for ActiproSoftware.Shared / SyntaxEditor / Text WPF dlls.
  2. Add the file from the Actipro Samples 'Dark.vssettings' as an embedded resource
  3. Copy the following code into 'WindowsFormsApp1.cs'
  4. Run the application, and you should see the MetroDark theme is used for everything except the scrollbars?
using ActiproSoftware.Windows.Controls.SyntaxEditor;
using ActiproSoftware.Windows.Controls.SyntaxEditor.Highlighting;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation;
using ActiproSoftware.Windows.Themes;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Forms.Integration;

namespace WindowsFormsApp1
    public partial class Form1 : Form
        private ElementHost elementHost;
        private SyntaxEditor syntaxEditor;

        public Form1()

            elementHost = new ElementHost();
            elementHost.Dock = DockStyle.Fill;
            syntaxEditor = new SyntaxEditor();
            elementHost.Child = syntaxEditor;

        protected override void OnLoad(EventArgs e)
                ThemeManager.AreNativeThemesEnabled = true;
                ThemeManager.CurrentTheme = ThemeName.MetroDark.ToString();

            var classificationTypes = AmbientHighlightingStyleRegistry.Instance.ClassificationTypes.ToArray();
            foreach (var classificationType in classificationTypes)

            new DisplayItemClassificationTypeProvider().RegisterAll();

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsApp1.Dark.vssettings"))

            CommonImageSourceProvider.DefaultImageSet = CommonImageSet.MetroDark;


[Modified 6 years ago]

Comments (2)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA


I believe the themes will not work correctly if a WPF Application hasn't been properly initialized in Application.Current.  WPF apps do this by default.  But in a WinForms app, if you simply create a new WPF Application() object at app startup before UI is referenced, it should inject one into Application.Current.

Actipro Software Support

Posted 6 years ago by (Anonymous)

Thanks it works now!

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

Add Comment

Please log in to a validated account to post comments.