-
Notifications
You must be signed in to change notification settings - Fork 678
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
WinUI3 Button XAML Template does not respect Foreground property after mouse passes over #7208
Comments
@RossCoeH I am unable to repro this in Windows App SDK 1.1. Can you try it out and see if it's still an issue? |
Definitely still a problem in Windows App SDK 1.1. and in SDK 1.0.3 `Window
`
This is the error causes by a missing template binding for Foreground in generic.xaml as stated earlier. You can view a demonstration application at https://github.com/RossCoeH/DemoBugButtonForeground. |
Unlikely to be a theming issue because the default Dark theme color will be white which is the same color as I have chosen - therefore after mouseover you would still be left with white, and you might conclude there is no error. But if you change the test to use another foreground color like "orange" as below then you should see the error in both light and dark modes - use a button like: |
My mistake, I can repro the bug. Thanks for the follow up! I've routed the issue. |
Did the routing cause this issue to get lost? |
Related to #6945 |
In this particular case, there is a template bind to the foreground property for the control. The foreground property is inherited by the ContentPresenter in the template. The PointerOver visual state is writing the foreground property and when going back to normal, the inhertited property is not going back to its original value. A workaround would be to explicitly set the foreground property on the ContentPresenter to a template binding instead of it getting inherited. That unfortunately needs a re-template. Testing a fix to WinUI3's button template. @michael-hawker There are other cases where the properties really need to be template bound instead of pointing to theme resources like you mention in your linked bug. |
Hi! Any progress on this please? And sorry but I am confused as to the workaround suggested - could you please clarify what the simplest way to solve this is at the moment, thank you. |
@Jimbo99 does this post not provide enough guidance on how to fix this issue in your app: https://nicksnettravels.builttoroam.com/fixing-broken-defaultbuttonstyle/ |
@krschau @michael-hawker any idea whether this is going to be fixed in the 1.2 release (it wasn't in the preview releases). |
Many thanks Nick! I will give that a try. |
FYI @gabbybilka |
@ranjeshj @kmahone @llongley who were the latest to work on this and can provide a status update. |
So, looks like v1.2 without this bug being fixed? seriously??? How bad does a bug need to be in order to get it fixed? |
🎉 Handy links: |
I am sorry to report that I still have the problem with release 1.2.230313.1 |
After a few days looking for a workaround i found that i was overriding the DefaultButtonStyle and i just needed to use BasedOn="DefaultButtonStyle" at all my button styles, so that there's no property missing anymore. Changed this: For this: |
Thank you very much for posting that, @OmarGGil! I am using 1.2.230313.1 and was still having the problem. Your mod fixed it for me. |
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.
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:
It should contain:
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
Device form factor
Desktop
Windows version
Windows 10 (21H2): Build 19044
Additional context
No response
The text was updated successfully, but these errors were encountered: