Xamarin - blinks when I replace the image source

I am working with xamarin formats and trying to create a navigation menu. I need to set a new image when I click on a cell. I have a blinking when I replace the image.

I am creating an image:

var image = new Image { Source = "Image.png"; } 

I add it to 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 the source and blink before setting a new image:

 image.Source = "NewImage.png" 

I tried

 image.BatchBegin() image.Source = "NewImage.png" image.BatchCommit() 

and thus How do I change the image source when I click on the ListView in xamarin.forms?

What is the best way to change the image?

+6
source share
2 answers

Not a direct solution, but if you change the image, why not revive it? it will even look good!

First fade out, then replace, and then fade out!

 await image.FadeTo(0, 250); image.Source = "NewImage.png"; await image.FadeTo(1, 250); 
+11
source

I found a solution - add two images and change the opacity to 0/1

+1
source

All Articles