ThemeManager.CurrentThemeChanged event thrown before being applied.

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 2 years ago by keepITcool - Amsterdam
Version: 22.1.2

To prep and change themes the documentation says to do following in app.OnStartup
.. create and register the custom stuff

CurrentTheme= "olala"

and indeed AFTER the EndUpdate I read the correct values for the 1048 AssetResourceKeys...

But I've got an eventhandler for the CurrentThemeChanged event. And that will read the old values as the event appears to be raised before the changes have been applied and written to Application.Current.Resources.MergedDictionaries(0).MergedDictionaries(0)

Am I missing something? When using the Begin/EndUpdate construct you'd expect the event to be raised AFTER the changes have been applied. Or should the code sample be amended, with the CurrentTheme being set after the EndUpdate?

Comments (1)

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


That is correct, the resources won't be updated until after the EndUpdate call if there is a BeginUpdate/EndUpdate construct.  As you suspected, if your CurrentThemeChanged event handler needs to examine actual resource values, I would recommend moving the CurrentTheme setter line until outside of the BeingUpdate/EndUpdate construct.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.