Bug 51296 - Problem changing style when button is disabled
Summary: Problem changing style when button is disabled
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-01-09 11:14 UTC by Hrafn Loftsson
Modified: 2017-02-16 10:01 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Hrafn Loftsson 2017-01-09 11:14:51 UTC
When a button's style is changed and the button is disabled (IsEnabled=false) the styling does not work. 

A sample solution is available at https://github.com/KolibriDev/TestXFBugs
This project has Xamarin.Forms installed.

To replicate the problem:

* Build and run the Droid project.
* Navigate to the PinPage from the LoginPage (by filling out all entries)
* Click twice on any button on the PinPage
* The text for the buttons disappears

When the user clicks twice on any button on the PinPage, all buttons become disabled and the style WhiteButtonDisabled is applied which should change the TextColor of the buttons. Instead, the text for the buttons disappears. Note that if the buttons are not disabled when changing the style, the styling works.
Comment 1 Stephane Delcroix 2017-02-15 14:06:26 UTC
XF doesn't expose properties to set disabled colors on controls. the style looks correctly applied, but given your style and the disabled state applied by android, your text is no longer visible. Tweak your style os that, once desaturated by android, you're still able to read the numbers

e.g., this style shows that the disabled style is applied, and the text is readable

 <Style x:Key="WhiteButtonDisabled" TargetType="Button">
        <Setter Property="BackgroundColor" Value="Red" />
        <Setter Property="TextColor" Value="Black" />
        <Setter Property="FontSize" Value="16" />
Comment 2 Hrafn Loftsson 2017-02-16 10:01:15 UTC
Thanks Stephane.

I have now changed the solution so it uses custom renderers to change text and background colors when the buttons are disabled.

It is strange, however, that the button's text on Droid is visible in XF, but not visible in XF