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...

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

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!

Posts

  • 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.