We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

IsEnabled Background Color MVVM

Thread ID:





149041 Nov 12,2019 01:34 PM UTC Nov 14,2019 09:35 AM UTC Xamarin.Forms 3
Tags: SfButton
Asked On November 12, 2019 01:34 PM UTC

Good day,

Kindly advise how to correctly set the BackgroundColor of a SfButton control when using the control in a MVVM pattern eg

                    Text="Ok" Command="{Binding OkBC}"
                    IsEnabled="{Binding OkEnable}"
                    BackgroundColor="Blue" />

The Button when OkEnable = True is enabled and  shows correct background color = Blue.
The Button when OkEnable=False is not enabled but shows incorrect background color = White.

Warm regards


Hemalatha Marikumar [Syncfusion]
Replied On November 13, 2019 08:57 AM UTC

Hi Ian, 
Greetings from Syncfusion. 
We have analyzed your query and we would like to let you know that using Disabled VisualState, you can customize the appearance of SfButton. Here we have achieved your requirement by changing the background color of disabled SfButton as per in below code snippet 
Code snippet[XAML]: 
<button:SfButton x:Name="button" Text="Ok" Command="{Binding OkBC}" IsEnabled="{Binding OkEnable}" BackgroundColor="Blue"> 
        <VisualStateGroup x:Name="CommonStates"> 
            <VisualState x:Name="Disabled"> 
                    <Setter Property="BackgroundColor" Value="Red" /> 
            <VisualState x:Name="Normal"> 
                    <Setter Property="BackgroundColor" Value="Blue" /> 
Please get back to us if you have any further questions on this. 
Hemalatha M. 

Replied On November 13, 2019 11:06 AM UTC

Good day,

I use the PRISM delegate commands as part of the MVVM implementation and found initially that the IsEnabled property was not reacting to changes to the bounded property. Adding CanExecute and RaiseCanExecuteChanged() to the mix remedied the situation.

In summary my question has been resolved using the following:

CanExecute in conjunction with DelegateCommand
Adding RaiseCanExcuteChanged to the set property of the ISEnabled binding.

Thank you for the support!

Warm regards


Hemalatha Marikumar [Syncfusion]
Replied On November 14, 2019 09:35 AM UTC

Hi Ian, 
Thanks for your update. 
We glad to hear that your requirement has been achieved.  
Please let us know if you need any other assistance. 
Hemalatha M. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon