Setup:
- .NET MAUI 8
- VS 2022 17.9.7
- Windows 11 24H2
- Samsung SM-A715F (Android 13.0 - API 33)
XAML:
<Image x:Name="MyImage"
HeightRequest="160"
Aspect="AspectFit"/>
Code-behind:
protected override void OnAppearing()
{
base.OnAppearing();
var filePath = Path.Combine(FileSystem.AppDataDirectory,
"test.jpg");
if (File.Exists(filePath))
{
MyImage.Source = ImageSource.FromFile(filePath);
}
}
It seems the above only works on Windows. It does NOT work on Android.
The following permissions are set in AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
I do NOT want to use FilePicker or anything like that.
The question is plain and simple: how to load image file from storage to .NET MAUI Image?
This GitHub issue seems related and still open since 2022! Anyone knows a workaround or third-party component that sorts this out?