FadeTo animation in xamarin forms in viewcell of listview

Hello All,
Am using a listview. The listview has an image in which I have to use fadeTo. I have to start/stop (or reset) fadeTo animation based on the value I get using bindable property.

The code of the bindable property change is this
Am extending my Image as

Class CustomImage : Image{

private static void OnCheckedPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
if ((bool)newValue)
{
((CustomImage)bindable).AnimateImage();
}
else
{
((CustomImage)bindable).CancelOrResetAnimation();
}
}

public void AnimateImage()
{
     this.FadeTo(0, 5000);
}

public void CancelOrResetAnimation()
{
    ViewExtensions.CancelAnimations(this);
}

}

Unfortunately ViewExtensions.CancelAnimations(this); doesn't work and my image continues with the fadeTo method and fades out the image.

Best Answers

Answers

  • george_isaac25george_isaac25 Member ✭✭

    I am using it inside a listview and I have to cancel animation say like every second and restart the animation if I get the flag as true.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Agree with FaizalSaidali , @george_isaac25 You shoud check If you can execute the CancelOrResetAnimation method.

  • george_isaac25george_isaac25 Member ✭✭

    Sorry for the late reply guys. It works only when I put a delay as @FaizalSaidali suggested.So for now am going with the delay.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Thanks for your sharing, If the issue was solved, please mark the answer that is helpful for you, it will help others who have similar issue.

Sign In or Register to comment.