0
votes

Ive built a Winforms RadForms application with VB.Net. The application contains several forms that contains several rad controls. The theme is changed by clicking a button. But it takes around 3-4 seconds for the theme to change. Now what I want to achieve is the application must show a message box with the message- "Theme Changed" when the theme has changed. I was wondering if there are any events that can be fired during a theme change and found one event named "ThemeNameChanged". I set it up like this:

Private Sub theme_changed (source as Object, args As ThemeNameChangedEventArgs) Handles Me.ThemeNameChanged
Msgbox("Theme Changed")
End Sub

Then I switch the theme with the click of a button:

Private sub Button1_Click(...) Handles Button1.Click ThemeResolutionService.ApplicationThemeName = "TelerikMetroBlue"
End Sub

But when click Button1 the theme changes but the message is not displayed once the theme has changed. So How Do I dsiplay a message when the theme has changed?

1
ThemeNameCahngedEventArgs this wont compile... ThemeNameChangedEventArgs that's what it should be. Also you don't have a routine name either. - zaggler
@Çöđěxěŕ thanks for the correction. I've now edited the question. - Somanna

1 Answers

0
votes

Setting the ThemeResolutionService.ApplicationThemeName property will style the entire application with the newly applied theme. However, in order to detect the theme changing in this case the ThemeResolutionService offers the ApplicationThemeChanged event:

    Sub New() 
    InitializeComponent()

    AddHandler ThemeResolutionService.ApplicationThemeChanged, AddressOf ThemeResolutionService_ApplicationThemeChanged

End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
    ThemeResolutionService.ApplicationThemeName = "Fluent"
End Sub

Private Sub RadButton2_Click(sender As Object, e As EventArgs) Handles RadButton2.Click
    ThemeResolutionService.ApplicationThemeName = "FluentDark"
End Sub

Private Sub ThemeResolutionService_ApplicationThemeChanged(sender As Object, args As ThemeChangedEventArgs)
    RadMessageBox.Show("Theme changed " & ThemeResolutionService.ApplicationThemeName)
End Sub