Bug 30097 - IsEnabled Property not working on button
Summary: IsEnabled Property not working on button
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-05-14 16:23 UTC by Anubhav Ranjan
Modified: 2017-01-03 18:46 UTC (History)
5 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 Anubhav Ranjan 2015-05-14 16:23:29 UTC
One of our customers is facing an issue with IsEnabled Property when used on a button.

I have noticed that if I data bind the IsEnabled property of a button to a bool value in my ViewModel, it doesn’t seem to work. However, If I hard code the value of IsEnable to false, it works just fine. I came across this because I have added a style trigger to the button in question, and noticed that the background colour only changed when the IsEnabled property is hard coded to false,

This appears to be the same kind of scenario that is reported in the following Bug Report: https://bugzilla.xamarin.com/show_bug.cgi?id=25752 and I have created a sample project at https://www.dropbox.com/s/1e6tolmx3gx9ddf/NavigationTest.zip?dl=0 that you can run and see the behaviour.

#Version Info:
=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: 626c2ec0-0341-42d7-b760-37e9acf75643
Microsoft .NET 4.0.30319.34014
GTK+ 2.24.22 (MS-Windows theme)
GTK# 2.12.26

=== Xamarin.Android ===

Version: 5.1.0 (Enterprise Edition)
Android SDK: C:\Users\CAtki_000\AppData\Local\Android\android-sdk
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 17:09:09-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 Chris King 2015-05-19 13:30:15 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the attached project. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue we would very much appreciate it. 

Warm regards,
Xamarin Forms Team
Comment 3 Chris Atkinson 2015-05-27 21:08:45 UTC
                I have narrowed down the issue to if you try and use a Button Trigger with a button style in XAML. Basically it appears that the Trigger is affecting the way the style is applied and the button state. But to me, this should be a valid scenario, because you may want the button to be disabled based on a particular scenario (in my case if a field is empty). So essentially the following doesn’t work:

<Button x:Name="Save" HorizontalOptions="CenterAndExpand" IsEnabled ="{Binding EnableSaveButton}" WidthRequest="300"     Grid.ColumnSpan="3"  Grid.Column="0" Grid.Row="2"  HeightRequest="50" Command="{Binding SaveCommand}" Text="Save" BackgroundColor ="{x:Static resources:ColourResources.PositiveButtonColour}">
                 <Style TargetType="Button">
                         <Trigger Property="IsEnabled" TargetType="Button" Value="false">
                             <Setter Property="Button.BackgroundColor" Value="Gray"/>
                <DataTrigger TargetType="Button"
                     Binding="{Binding Source={x:Reference cardNumber},
                  <Setter Property="IsEnabled" Value="False" />


But by removing the trigger above and using the Style, the style appears to wor.
Comment 4 Chris Atkinson 2015-05-27 21:26:14 UTC
Sorry, that last word should have been "work".
Comment 5 Baranidharan 2016-03-02 18:54:46 UTC
I have the same issue as above with 2.0. Any workarounds or fixes for this?
Comment 6 Jimmy [MSFT] 2017-01-03 18:46:58 UTC
There was a typo in the property name inside the viewmodel and after fixing that I can no longer reproduce the issue with the provided project. 

If you continue seeing this issue with the latest version of Forms, please re-open this report with an updated repro project. Thanks!