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();
}
Private Sub RadForm_WindowsThemeChanged(sender As Object, e As WindowsThemeChangedEventArgs)
Dim newTheme As WindowsTheme = e.CurrentTheme
If newTheme = WindowsTheme.Light Then
Me.BackColor = Color.LightBlue
ElseIf newTheme = WindowsTheme.Dark Then
Me.BackColor = Color.DarkBlue
ElseIf newTheme = WindowsTheme.HighContrast Then
Me.BackColor = Color.Black
End If
Me.Text = "Windows Theme is " & newTheme.ToString()
End Sub