New to Telerik UI for WinForms? Download free 30-day trial

Detect Theme Change

As of R1 2022 SP1 RadForm offers the WindowsThemeChanged event which can be used to determine when OS theme change occurs at run-time. Its main purpose is to detect any theme changes on OS level in order to adjust the application theme.

The WindowsSettings.CurrentWindowsTheme can be used to detect the currently active windows theme.


private void RadForm_WindowsThemeChanged(object sender, Telerik.WinControls.WindowsThemeChangedEventArgs e)
{
    WindowsTheme newTheme = e.CurrentTheme;
    if (newTheme == WindowsTheme.Light)
    {
        this.BackColor = Color.LightBlue;
    }
    else if (newTheme == WindowsTheme.Dark)
    {
        this.BackColor = Color.DarkBlue;
    }
    else if (newTheme == WindowsTheme.HighContrast)
    {
        this.BackColor = Color.Black;
    }

    this.Text = "Windows Theme is " + newTheme.ToString();
}
In this article