Hello,
You could use the GetPlatformImageAsync
method and determine whether the returned result is empty to determine whether the image is loaded successfully, please refer to the following code example:
<Image x:Name="img"
Loaded="Image_Loaded"
Source="dotnet.png"
...
/>
private async void Image_Loaded(object sender, EventArgs e)
{
var res = await img.Source.GetPlatformImageAsync(Handler.MauiContext);
if (res == null)
{
img.Source = "dotnet_bot.png";
}
}
Best Regards,
Alec Liu.
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.