Replies: 2 comments
-
Hey there! The best way to accomplish this would be to implement the themes as XAML ResourceDictionary instances (which can contain both simple resources like colors and full-blown templates that completely redesign the control). Normally, these files are parts of the app’s source code and are compiled into non-editable XBF files during the build process. However, there is the XamlReader class. This allows an app to load XAML content from a text string at runtime, using the exact same syntax you would write in Visual Studio. The documentation gives the example of loading an Ellipse instance, but I suppose that the same would work for a ResourceDictionary. Once that is done, you would insert the new ResourceDictionary into As to how to create a visual designer that edits colors on these themes, you would have to read in the theme XAML from a file, and then either make changes to the string in memory before it is loaded (very powerful, but difficult), or to change out the resources in the dictionary after loading them but before inserting it into Please be aware that I’ve never tried this technique myself, so I have no idea if it will work or not, or what tradeoffs there would be. In particular, I don’t know how to force the controls currently onscreen to redraw themselves using the new resources; you may need to perform the above technique only during the app startup sequence, before any windows are created, for it to work. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Thank you, @wjk! I will try to use the approach suggested by you. |
Beta Was this translation helpful? Give feedback.
-
Hello!
In our components, we want to have the ability to change themes. The main requirements which we want to fit are:
Could you suggest the best approach to solve this? Which way to go?
Beta Was this translation helpful? Give feedback.
All reactions