Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Button backgroundcolor not working if canexecute is false #14867

Open
snice1981 opened this issue Nov 10, 2021 · 8 comments
Open

[Bug] Button backgroundcolor not working if canexecute is false #14867

snice1981 opened this issue Nov 10, 2021 · 8 comments

Comments

@snice1981
Copy link

Description

The button background color is ignored if the canexecute is false. Once it becomes true, the background color becomes blue even if you set another color

Steps to Reproduce

  1. Create a Shell App with content page
  2. Add a button with backgroundcolor set to any color and bind its command with a canexecute to false
  3. Run the app

Basic Information

  • Version with issue: 5.0.0.2196
  • Platform Target Frameworks:
  • Android: 11

Screenshots

image

image

if SubscribedSession is null, the button is disabled and the color is blue (which I didn't set!)
image

if SubscribedSession is not null, the button is enable and the color is blue (which I didn't set!)
image

If I force the canexecute to true, the button is enabled and the color is fine
image

image

@snice1981 snice1981 added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 10, 2021
@jfversluis
Copy link
Member

Please do not post code as screenshots, then I will all have to type it over which doesn't help getting this resolved quicker :)

Also, would you mind adding a little sample application that shows this problem?

@jsuarezruiz jsuarezruiz added this to New in Triage via automation Nov 11, 2021
@jsuarezruiz jsuarezruiz added a/button p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Nov 11, 2021
@jsuarezruiz jsuarezruiz moved this from New to Needs Info in Triage Nov 11, 2021
@snice1981
Copy link
Author

sorry for the screenshot, I thought it would be easier to read as it's colored, compared to the code tag:

<Button Grid.Row="3" Grid.Column="2" Command="{Binding ShareCommand}" Margin="10,0" BackgroundColor="{StaticResource Secondary}" CornerRadius="15"> <Button.ImageSource> <FontImageSource FontFamily="Material" Color="White"> <FontImageSource.Glyph> <OnPlatform x:TypeArguments="x:String"> <OnPlatform.Platforms> <On Platform="iOS" Value="&#xe6b8;" /> <On Platform="Android" Value="&#xe80d;" /> </OnPlatform.Platforms> </OnPlatform> </FontImageSource.Glyph> </FontImageSource> </Button.ImageSource> </Button>

What do you mean a sample of application? because the screenshots I sent are from the android emulator. But here is a full page screenshot

image

The 2 concerned buttons are disabled

@jfversluis
Copy link
Member

What I mean with a sample application is a reproduction. Try to create a new Xamarin.Forms application, add a button and see if it behaves the same way there. That will help us determine if it is indeed a bug in the Xamarin.Forms library, or maybe something in your code that is causing this.

Also, it will help us see all the code you added to that sample project in order to lead up to the bug. That way we can see clearly what code is involved and diagnose quicker.

@snice1981
Copy link
Author

Ok here we go: I just created a new fresh Shell App.

I just added 3 buttons exactly the same on the AboutPage.Xaml.
The button 1's canexecute command is set to false (the color is wrong)
The button 2's canexecute command is set to true (the color is fine)
The button 3's canexecute command is toggled by a fourth button (the color is wrong)

You can find the full code here

image

I paste images of the code for visibility (you have the text code in the repository)

image

image

@jfversluis
Copy link
Member

This is wonderful, thank you!

@jfversluis jfversluis removed the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Nov 11, 2021
@snice1981
Copy link
Author

@snice1981
Copy link
Author

I also noticed if, I change the color while running the app (hot reload), the color is fine

@jsuarezruiz
Copy link
Contributor

The Blue color is from a Style at App level. Said that, setting the BackgroundColor property must apply a color regardless of style or state.

@jsuarezruiz jsuarezruiz moved this from Needs Info to Ready For Work in Triage Nov 25, 2021
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Ready For Work
Development

No branches or pull requests

3 participants