fluentribbon / Fluent.Ribbon

WPF Ribbon control like in Office
http://fluentribbon.github.io
MIT License
2.56k stars 517 forks source link

Changing Colors of Fluent Ribbon Control items from code behind #1031

Closed labdha closed 2 years ago

labdha commented 2 years ago

Hi, I am very new to Fluent Ribbon control. Presently I am working on a code where in I have used Fluent Ribbon (V9.0.4) and need to give the user the preference to change background colors of ribbon tab control, backstage, tab grid, title bar, tab content etc. I searched a lot in the net nut could not find a relevant solution to my problem i.e how I can change background colors of ribbon item from code behind on button click. Can someone guide me to achieve my goal? Though I did find the following solution to change the theme of the ribbon but not the individual items separately. Thanks

ResourceDictionary newRes = new ResourceDictionary();
newRes.Source = new Uri(theme, UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Clear();
this.Resources.MergedDictionaries.Add(newRes);
batzen commented 2 years ago

To generate a new theme you can have a look at https://github.com/fluentribbon/Fluent.Ribbon/blob/238329bdc4a0ba5f1e10392afb861b700d126346/Fluent.Ribbon.Showcase/TestContent.xaml.cs#L539

If you want to change individual colors/brushes you can overwrite single resources. The list of all resource keys used by Fluent.Ribbon can be found at https://github.com/fluentribbon/Fluent.Ribbon/blob/develop/ReferenceData/vCurrentResourceKeys.txt