Accessing ribbon brushes for use in custom controls

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 16 years ago by Philipp Schmid
Version: 4.0.0456
Avatar
For the live of me I cannot figure out how to get to a Brush from RibbonCommonDictionary.WindowBackgroundBrushKey in code (not XAML). I want to use it in a IValueConverter to set a button's background.

Philipp

Comments (1)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Philipp,

Any FrameworkElement has FindResource and TryFindResource methods you can call. You pass a ResourceKey to those (like the value of RibbonCommonDictionary.WindowBackgroundBrushKey) and you get back the Brush. You need to cast to it of course. I'd recommend TryFindResource since it doesn't blow up if the resource isn't found.

Also Application has those two methods as well. As long as you set ThemeManager.CurrentTheme, instead of setting themes at a Window level for instance, I believe calls to Application.TryFindResource will work as well.


Actipro Software Support

The latest build of this product (v24.1.3) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.