Skip to content

WinUI3 Button XAML Template does not respect Foreground property after mouse passes over #7208

@RossCoeH

Description

@RossCoeH

Describe the bug

In WInUI 3, create a Button with:

<Button Name="Undo1" Content="Undo." Background ="DarkSlateBlue" Foreground ="White"/>
On starting the app, the colors are correct, but after moving the mouse over the button, the text color will remain black rather that white as specified with Foreground property.
ice_video_20220608-182052_edit_0

Steps to reproduce the bug

as above.

Note that the key issue is that the default template for Button (inside generic.xaml) does not have a templatebinding for Foreground, but includes Background.
My reference for the template is:
C:\Users.....nuget\packages\microsoft.windowsappsdk\1.0.3\lib\net5.0-windows10.0.18362.0\Microsoft.WinUI\Themes

The template contains:

      <Setter Property="Background" Value="{ThemeResource ButtonBackground}" />

It should contain:

      <Setter Property="Background" Value="{ThemeResource ButtonBackground}" />
      <Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />

Expected behavior

Foreground color property should be reset to original color after the mouse has left the button zone. It will do that if the generic template is updated as suggested

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.0.3

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions