Hello,
I check your sample, and I found you set null
if the imagesource
is null in ToBitmapDrawable
method, try to set it a default instance, refer to the following code:
public static async Task<BitmapDrawable> ToBitmapDrawable( this ImageSource imageSource, CancellationToken cancellationToken = default)
{
if (imageSource == null)
return new BitmapDrawable();
Bitmap bitmap = await imageSource.ToBitmap(cancellationToken);
return new BitmapDrawable(MainActivity.Instance.Resources, bitmap);
}
And try to set your LeadingImageSourceProperty
as a BindableProperty, add the following code into your MaterialEntry
class:
public static readonly BindableProperty LeadingImageSourceProperty =
BindableProperty.Create(nameof(IMaterialEntry.LeadingImageSource), typeof(ImageSource), typeof(IMaterialEntry));
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.