Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding Text Color on Mouse Over on RibbonTabItem #534

Closed
scauthen opened this issue Feb 21, 2018 · 3 comments
Closed

Overriding Text Color on Mouse Over on RibbonTabItem #534

scauthen opened this issue Feb 21, 2018 · 3 comments
Assignees

Comments

@scauthen
Copy link

scauthen commented Feb 21, 2018

I am having trouble styling the text color when a RibbonTabItem is hovered over. I have used styles to redefine several items on the Ribbon. How can I change the text color on hover to say White or another light color?
Thank you very much for your time!

<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabControl.Background" Color="Transparent" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabControl.Content.Background" Color="#f1f1f1" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabControl.Content.BorderBrush" Color="Red" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabControl.Content.Foreground" Color="Black" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabControl.TabsGrid.Background" Color="#2b579a" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabControl.TabsGrid.Foreground" Color="Black" />

<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabItem.Foreground" Color="White"  />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabItem.BorderBrush" Color="#2b579a" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabItem.Active.Background" Color="#f1f1f1" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabItem.MouseOver.Background" Color="#4067a4" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabItem.MouseOver.BorderBrush" Color="#2b579a" />
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.RibbonTabItem.Selected.Foreground" Color="#2b579a"  />

menu-tab-wrongcolor

If you have answered this previously, I apologize. I could not find it addressed.


Environment

  • Fluent.Ribbon v6.1.0.233
  • Windows 10
  • .NET Framework 4.5.2
@batzen
Copy link
Member

batzen commented Feb 22, 2018

There is a trigger which prevents you from overriding it the way you tried it.

Can try it right now, but the following should to the job:

<Style x:Key="{x:Type Fluent:RibbonTabItem}"
       TargetType="{x:Type Fluent:RibbonTabItem}">
    <Setter Property="Fluent:RibbonProperties.MouseOverForeground"
            Value="{DynamicResource Fluent.Ribbon.Brushes.HighlightBrush}" />
</Style>

If above does not work, a trigger on your style having the same setter should work.
If that also does not work, you definitely have to set the attached property Fluent:RibbonProperties.MouseOverForeground on the RibbonTabItem somehow.

@batzen batzen self-assigned this Feb 22, 2018
@scauthen
Copy link
Author

scauthen commented Feb 22, 2018

Thank you for the help. I was able to override it using the following code:

<Style TargetType="{x:Type Fluent:RibbonTabItem}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="False" />
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Foreground" Value="White" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="True" />
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background" Value="Transparent" />
                    <Setter Property="Foreground" Value="{DynamicResource AccentBrushDark}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="True" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Foreground" Value="{DynamicResource AccentBrushDark}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

@batzen
Copy link
Member

batzen commented Feb 23, 2018

Please note that you might get problems with this when switching from BaseLight to BaseDark colors or vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants