Add custom resource keys to Actipro themes

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 2 months ago by BenjaminLopVic - France
Version: 25.1.1
Avatar

Hello,
I want to add a new global resource key (a new brush) to my application, and I’d like it to change automatically when the Actipro theme changes.
Is it possible to add custom keys to Actipro themes?

I’ve seen the ThemeSamples\ThemeOverride QuickStart, which is great — but it only shows how to modify existing assets, not how to add new ones.

Thanks

Comments (5)

Answer - Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Actually that is the correct sample to look at and you can add any resources you want using the techniques in there.  For example. we add a new DialogButtonStyle Style, which isn't a built-in resource from our themes.  You could do the same thing but with a new custom brush.


Actipro Software Support

Posted 2 months ago by BenjaminLopVic - France
Avatar

I’ll try that! But do you know how to do it in a non-standalone WPF application?
I’m using Actipro in a VSTO application, and I get this error when I try to add it:

Error XDG0008: ResourceDictionary is not supported in a Windows Presentation Foundation (WPF) project.

My project does reference WPF correctly — I can create WPF UserControls without any problem.

Thanks.

Posted 2 months ago by BenjaminLopVic - France
Avatar

Also, I tried this in a standalone WPF application, and I couldn’t get it working there either.
I’m using three different ThemeDefinitions — OfficeBlack, OfficeGray, and OfficeWhite — each with an associated ThemedResourceDictionaryReference.

But my CustomBrush doesn’t use the correct dictionary:

  • The black and gray themes both use the white dictionary,

  • And the white theme doesn’t use any of them.

You can find the full code here: github.com/BBJ-Artecomm/ActiproThemeSample
Thanks!

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

Hello,

Thank you for the sample.  The problem there is that in your OfficeThemeCatalog, it looks like you copied it from our sample and where we had a catch-all "other" resource dictionary with AreThemesExclusive = true, you switched that to OfficeWhite but didn't remove the AreThemesExclusive = true setting.  If you remove that line, it works as you intended.

Regarding the XDG008 error you mentioned, I'm not sure what that is since we don't test in VSTO scenarios.  It would seem to be something lower level than what we are doing though.  What has changed that triggers that error, and is it at compile or run-time?  Were you able to solve it?


Actipro Software Support

Posted 2 months ago by BenjaminLopVic - France
Avatar

AreThemesExclusive was the problem!
However, I didn’t really understand what this property does, and I couldn’t find much information about it in the documentation.

As for the VSTO part, I ended up putting the theme configuration in a separate WPF project.
I’d prefer to do that directly in the main VSTO project, but I haven’t found a good way to make it work yet.

The latest build of this product (v25.1.2) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.