Skip to content

Dark mode, the scroll bar theme is incorrect. #10665

Description

@Eviav

.NET version

.net6.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

all

Issue description

After enabling dark mode, the scroll bar remains in the light theme.

DarkTestGIF

        private void button1_Click(object sender, EventArgs e)
        {
            Dark = !Dark;
        }

        bool dark = false;
        public bool Dark
        {
            get => dark;
            set
            {
                dark = value;
                if (value)
                {
                    BackColor = Color.Black;
                    ForeColor = Color.White;
                }
                else
                {
                    BackColor = Color.White;
                    ForeColor = Color.Black;
                }
                int useImmersiveDarkMode = value ? 1 : 0;
                DwmSetWindowAttribute(Handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref useImmersiveDarkMode, sizeof(int));
            }
        }

        #region DarkDwm

        [DllImport("dwmapi.dll")]
        static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);

        const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;

        #endregion

DarkTest.zip

Steps to reproduce

After invoking "Dark=true", the scroll bar color remains in the light theme.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions