ThemeManager.CurrentThemeChanged event thrown before being applied.

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 2 months ago by keepITcool - Amsterdam
Version: 22.1.2
Avatar

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

AreNativeThemesEnabled=True
CurrentTheme= "olala"
EndUpdate()

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 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

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 (v22.1.3) was released 23 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.