Problem with setting a buttons gradient

Dangermouse500Dangermouse500 Member ✭✭
edited March 15 in Xamarin.Forms

Hi, I have a button which I want to change the look of it (appear almost disabled) based on a boolean flag I set. I've noticed that it won't appear correctly the first time it loads. When going back to the page, it is fine. Here's a snippet of my code...

                Command="{Binding InstallCommand}"
                Caption="{i18n:Translate HomeInstallDesc}"
                Title="{i18n:Translate HomeInstallTitle}"
                    <DataTrigger TargetType="gt:Button2" Binding="{Binding CanInstall}" Value="true">
                        <Setter Property="BackgroundTopColor" Value="{StaticResource BlueGradStart}" />
                        <Setter Property="BackgroundBottomColor" Value="{StaticResource BlueGradEnd}" />
                    <DataTrigger TargetType="gt:Button2" Binding="{Binding CanInstall}" Value="false">
                        <Setter Property="BackgroundTopColor" Value="{StaticResource BlueGradStartTrans}" />
                        <Setter Property="BackgroundBottomColor" Value="{StaticResource BlueGradEndTrans}" />

I've also noticed that if I place IsVisible="{Binding CanInstall}" in the Button2 control's definition above then the functionality works fine but I don't want this. Can somebody please explain why this is working as described and how I can resolve this? I've tried adding code in the Appearing method (override) but this hasn't helped. Thanks!


  • Dangermouse500Dangermouse500 Member ✭✭

    This was caused by code behind on the custom control interfering with the loading. I've changed this so that it uses Opacity rather than use Background Colors and the problem has been resolved.

Sign In or Register to comment.