RibbonColorScheme setting within xaml

Ribbon for WPF Forum

Posted 16 years ago by Brandon Simmons - Programmer, AssimilSoft
Version: 3.0.0410
Avatar
Here is something that I've done that some other people might find useful (maybe it will be included in a future version? :) )

Anyway, the purpose here is to allow setting of the default ribbon color scheme from within your xaml code. I'm using an attached property on my ribbon tag to achieve the result.

Here is the class defining the attached property.

using System.Windows;
using ActiproSoftware.Windows.Controls.Ribbon.UI;

namespace Common.UI
{
    public class RibbonColorSchemeSetter
    {
        public static readonly DependencyProperty ValueProperty;

        static RibbonColorSchemeSetter()
        {
            ValueProperty = DependencyProperty.RegisterAttached("Value", typeof(RibbonColorScheme), typeof(RibbonColorSchemeSetter),
                new PropertyMetadata(OnValueChanged));
        }

        public static RibbonColorScheme GetValue(DependencyObject sender)
        {
            return (RibbonColorScheme)sender.GetValue(ValueProperty);
        }

        public static void SetValue(DependencyObject sender, RibbonColorScheme value)
        {
            sender.SetValue(ValueProperty, value);
        }

        private static void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RibbonColorScheme.Default = (RibbonColorScheme)e.NewValue;
        }
    }
}
And here is the usage within xaml code.

<r:Ribbon ui:RibbonColorSchemeSetter.Value="{x:Static r:RibbonColorScheme.Office2007Black}"/>

Comments (4)

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

Thanks for the post. That will certainly be helpful for anyone running v3.0.

Actually in v3.5, we invested a lot of time into a themes framework that all our v3.5 controls now use. And in that we made it so that each brush has its own resource key which you can easily override with your own brush. Going along with this we don't really have the color scheme class any more. Instead, the brushes are defined directly with the colors and is done completely in XAML. The v3.5 documentation has a lot of info on the themes framework.


Actipro Software Support

Posted 16 years ago by Brandon Simmons - Programmer, AssimilSoft
Avatar
Cool, thanks for the info.

I have already used my free upgrade so I'm not able to use 3.5 yet. When you release your docking and syntax editor controls I will most likely purchase another subscription.
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Your subscription goes through June so you can get v3.5 now for free! :)


Actipro Software Support

Posted 16 years ago by Brandon Simmons - Programmer, AssimilSoft
Avatar
Thanks, I don't think the Free Upgrade link was there earlier. I couldn't find a specific example in the documentation on setting the theme in xaml so I'll post it here in case anyone is looking for it.

This is version 3.5+ compatible.

<r:Ribbon themes:ThemeManager.Theme="{Binding Source={x:Static themes:CommonThemeName.Office2007Black}}"/>
The latest build of this product (v24.1.1) 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.