Is there a way to preview DynamicResources that are merged into App.xaml resouces?

32 Views Asked by At

I have an app in WPF and created a service that adds my brushes and colors into a ResourceDictionary and then merges this dictionary with App.xaml resources. This looks somethings like this (obvously the original code is bigger. This is the main idea):

private void ConfigureApplicationVisual()
{
    Resources.MergedDictionaries.Add(new AbdrakovBundledTheme()
    {
        IsDarkMode = true,
        ExtendedColors = new Dictionary<string, ColorPair>()
        {
            { "TextForeground", new ColorPair(Colors.AliceBlue, Colors.Black) },
            // similar things...
        }
    }.SetTheme());
}

(Then inside SetTheme method colors are adding into AbdrakovBundledTheme (that is inheritted from ResourceDictionary) like sourceDictionary[name + "Color"] = value; and returns the AbdrakovBundledTheme as dictionary to be merged further)

So what do I want? I want the colors to appear in design mode (as StaticResources do). I know that WPF compiles and runs some blocks of code at runtime to show them in designer. Is it possible to do this with DynamicResources?
Two more things:

  1. I already saw similar question on SO Preview of dynamicresources in WPF but I can't do as they did. My AbdrakovBundledTheme is also kinda dynamic.
  2. I tried to call the method in App constructor and in OnStartup but there was no result.
0

There are 0 best solutions below