glidex
glidex copied to clipboard
NotSupportedException thrown when using with XF CollectionView
A System.NotSupportedException
is thrown under the following circumstances:
- GlideX.Forms is used with a Xamarin.Forms application.
- An
Image
control is contained with anItemTemplate
inside aCollectionView
- The list is long enough to permit scrolling up and down.
When scrolling occurs and native view holders are recycled, the following exception is thrown:
System.NotSupportedException: 'Unable to activate instance of type Android.Glide.ImageButtonRenderer from native handle 0x7fd4ed7484 (key_handle 0xab8c93f).'
It is interesting to note the same exception is thrown without GlideX when using an ImageButton
, so it is not directly related to the GlideX.Forms package but it may need to be resolved in the renderer. I believe it may be related to the following issue. We have used the following workaround in a custom renderer:
public ImageButtonRenderer(IntPtr handle, JniHandleOwnership transfer) : base(CrossCurrentActivity.Current.AppContext)
{
// TODO: Remove this workaround once fixed in XF.
// This doesn't address the root cause, but prevents "System.NotSupportedException: Unable to activate instance of type" from being thrown.
// Refer: https://stackoverflow.com/questions/10593022/monodroid-error-when-calling-constructor-of-custom-view-twodscrollview/10603714#10603714
}
What are your thoughts on this @jonathanpeppers?
@velocitysystems can you make a sample page in this project that shows the problem?
https://github.com/jonathanpeppers/glidex/tree/master/glidex.forms.sample/Forms
It seems like I will have to debug what is going on. I also test these pages manually every time I release, so it would be nice to verify nothing breaks CollectionView
as we move forward. 👍
Hi @jonathanpeppers. I have put up #68 which adds a CollectionView
sample.
Unfortunately, it doesn't reproduce the problem we are facing so will need to investigate further. But I thought I'd put it up anyway as it is a sample using the new CollectionView
control.
I'll need to dig a little deeper and see why our ItemTemplate's are blowing up when using GlideX.
@velocitysystems the sample looks great, let me know if you figure out how to cause the issue!
Maybe it's something about the layout you have setup in the CollectionView.ItemTemplate
your app? Some combination of controls + bindings?