When I use the code below, I have a problem that the Image in CarouselView is not displayed, how can I fix this by leaving the Canvas error solution method: trying to use a recycled bitmap android.graphics.Bitmap maui
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
...
#if ANDROID
ImageHandler.Mapper.PrependToMapping(nameof(Microsoft.Maui.IImage.Source),
(handler, view) => PrependToMappingImageSource(handler, view));
#endif
return builder.Build();
}
#if ANDROID
public static void PrependToMappingImageSource(IImageHandler handler,
Microsoft.Maui.IImage image)
{
handler.PlatformView?.Clear();
}
#endif
}
Here is the code of my CarouselView
using PDconfigurator.Helpers;
namespace PDconfigurator.View.Controls;
public partial class ImageModalPage : ContentPage
{
public ImageModalPage(List<ImageSource> imageSources, int initialIndex)
{
InitializeComponent();
carouselView.ItemsSource = imageSources;
carouselView.KeepCarouselPosition(initialIndex);
if (imageSources.Count == 1)
{
carouselView.IsSwipeEnabled = false;
}
}
private async void OnSwipe(object sender, SwipedEventArgs e)
{
await CloseModal();
}
private async Task CloseModal()
{
await App.Current.MainPage.Navigation.PopModalAsync();
}
}