Accessing ribbon brushes for use in custom controls

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 11 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 11 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 (v2019.1 build 0681) 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.