I am working with xamarin forms and trying to create navigation menu. I need to set new image when i click on cell. I have some blinking when i replace image.
I create image:
var image = new Image { Source = "Image.png"; }
I add it on my grid
var profileTapRecognizer = new TapGestureRecognizer();
profileTapRecognizer.Tapped += (sender, e) =>
{
ItemClicked(sender as ITaggedCell);
};
image.GestureRecognizers.Add(profileTapRecognizer);
grid.Children.Add(image, i, 0);
And in ItemClicked i change source and have blink before new image was set:
image.Source = "NewImage.png"
I tried
image.BatchBegin()
image.Source = "NewImage.png"
image.BatchCommit()
and this way How to change Image Source while clicking on the ListView in xamarin.forms?
What is the best way to change image?
Not a direct solution, but if you're changing image, why not animate? that would even look good!
First fade out, then replace, then fade in!
await image.FadeTo(0, 250);
image.Source = "NewImage.png";
await image.FadeTo(1, 250);
I found the solution - to add two images and change opacity to 0/1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With