I want to implement ASP.Net type theme in WPF. User have selection of various predefined themes and can switch to another theme.
To implement this I have tried by creating different resourcedictionary for each theme and store required style with key. The collection of keys are same in all themes but its definition is different in each.
I am using below code to switch theme on click:
var theme = Application.LoadComponent(uri) as ResourceDictionary;
Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(theme);
In all pages/ usercontrol/ windows I have set StaticResource and applied appropriate key. When I switch to another theme it is only applied after next event on UI.
If I set change StaticResource to DynamicResource then it is applied on immediately.
Please share your idea to achieve this with StaticResource?