Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFImageLoading advanced useage #37

Open
Wenfengcheng opened this issue Mar 26, 2019 · 0 comments
Open

FFImageLoading advanced useage #37

Wenfengcheng opened this issue Mar 26, 2019 · 0 comments

Comments

@Wenfengcheng
Copy link
Owner

If you use CachedImage views inside ViewCells used by ListViews with ListViewCachingStrategy.RecycleElement enabled, don't rely on bindings for setting the Source property (they are so slow!) - please use ViewCell's OnBindingContextChanged override of a ViewCell implementation to update it, avoiding loading images to wrong views. Example:

public class MyCustomCell : ViewCell
{
	readonly CachedImage cachedImage = null;

	public MyCustomCell()
	{
		cachedImage = new CachedImage();
		View = cachedImage;
	}

	protected override void OnBindingContextChanged()
	{
		// you can also put cachedImage.Source = null; here to prevent showing old images occasionally
		cachedImage.Source = null;
		var item = BindingContext as Item;

		if (item == null)
		{
			return;
		}

		cachedImage.Source = item.ImageUrl;

		base.OnBindingContextChanged();
	}
}

https://github.com/luberda-molinet/FFImageLoading/wiki/Xamarin.Forms-Advanced
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/listview/performance#RecycleElement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant