Windows-XAML / Template10

Making Windows 10 apps great again
Apache License 2.0
1.41k stars 389 forks source link

PrimaryCommands foreground hover colour? #1240

Closed Mrtenz closed 8 years ago

Mrtenz commented 8 years ago

I'm trying to set the foreground colour of a AppBarButton in the PageHeader's PrimaryCommands. Currently my XAML looks like this:

<controls:PageHeader.PrimaryCommands>
    <AppBarButton Icon="Refresh" Label="Refresh"
                  Click="{x:Bind ViewModel.Refresh}"
                  Foreground="White" />
</controls:PageHeader.PrimaryCommands>

But when hovered the foreground colour is black. How would I change this to white as well?

dg2k commented 8 years ago

When you start setting colors individually as you did with Foreground="White", it's a sippery slope for things to get complicated because the theme setting as a whole and your color setting are not in unison. Why you get black on hover is because your App Theme is Light and the system picks the default background for the Light Theme which is black. If you switch to Default/Dark, the hover will be white.

Mrtenz commented 8 years ago

So I've added Style="{ThemeResource PageHeaderStyle}" to the PageHeader control, but the AppBarButton colour was still black when hovered. I managed to fix this by using RequestedTheme="Dark", but is there no way to set the actual Foreground colour when hovered?

dg2k commented 8 years ago

No, you cannot change the hover from the default as things stand without changing the control template. By default what the hover does is:

Now the tricky bit is if you changed the AppBarButton Foreground as you first indicated, hovering simply resets back the Foreground creating an illusion as if hovering is actually changing the foreground. No, it's simply resetting to the original (before you changed it). This is a source of confusion. If you really want to use a different color scheme for hovering, then you should consider changing the style template for the control (you're effectively modifying the internal Visual State corresponding to the hover state). This, you'll understand, is outside the scope of T10 but of course developers’ prerogative to do whatever.

Perhaps these facts about T10 will dispel the confusion:

Mrtenz commented 8 years ago

Okay, thanks.