79111846

Date: 2024-10-21 21:51:10
Score: 1.5
Natty:
Report link

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();
}
}
Reasons:
  • Blacklisted phrase (0.5): how can I
  • Blacklisted phrase (1): how can I fix this
  • Long answer (-1):
  • Has code block (-0.5):
  • Starts with a question (0.5): When I use the code
  • Low reputation (1):
Posted by: Влад Гурковский