How to use a theme resource from code?

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 12 years ago by Kasper
Version: 11.2.0554
Avatar

Hi guys,

This seems like such a simple question, and yet I haven't been able to find the answer yet: How do I access one of your themed resources, e.g. RibbonTabControlBackgroundNormalBrushKey, from code (not XAML)? I wish to use the brush as Background on a panel that I generate at runtime. It's pretty easy to do from XAML, which your documentation and sample app demonstrates very well, but how can I do it from good, old C# code?

Comments (2)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

There are TryFindResource and FindResource methods both on Application instances and on every FrameworkElement instance that you can use.  For instance, see these MSDN docs.

I believe you can probably use the Application one directly since we load our themed brushes into the Application's resources.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

Thanks! I had already tried that, but I missed the fact that I could use AssetResourceKeys.RibbonTabControlBackgroundNormalBrushKey directly - instead I tried to provide the key as a string, which is why it didn't work out for me :)

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.