I'm developing an App for Android and UWP. In one screen I need to load an image from the device-filesystem and display it. Strangely it works perfectly on Android, but not on UWP. The Paths seem to be returned correctly by the FilePicker...
My XAML
<Image Grid.Row="0" Grid.Column="0"
Source="{Binding NewImage}" Margin="10,10,10,10" Aspect="AspectFit"
VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" />
The source i use for the image
private FileImageSource _newImage;
public FileImageSource NewImage
{
get { return _newImage; }
set
{
_newImage = value;
OnPropertyChanged(nameof(NewImage));
}
}
The function which is supposed to load the image and set the path.
private async void OnAddImage()
{
string[] types = { ".jpg", ".png" };
FileData temp = await CrossFilePicker.Current.PickFile(types);
if (temp == null)
{
return;
}
Debug.WriteLine($"ImagePath: {temp.FilePath}");
Debug.WriteLine($"ImageName: {temp.FileName}");
NewEntry.ImagePath = temp.FilePath;
NewImage = (FileImageSource)ImageSource.FromFile(temp.FilePath);
}