Hi, I am trying to take a picture via android camera in my viewmodel and then update the Image control on the xaml page.
How do I get the picture from the ViewModel refreshed in my xaml page? The camera plugin take the image and then return to my application, but the photo on my screen never show?
public FileUploadCaptureViewModel([NotNull] INavigationService navigationService) : base(navigationService)
{
TakePhotoCommand = new Command(async () =>
{
if (Xamarin.Essentials.MediaPicker.IsCaptureSupported)
{
await Task.Run(async () =>
{
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "",
SaveToAlbum = true,
CompressionQuality = 75,
CustomPhotoSize = 50,
PhotoSize = PhotoSize.MaxWidthHeight,
MaxWidthHeight = 2000,
DefaultCamera = CameraDevice.Front
});
if (file == null)
return;
UploadPhoto = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});
});
}
public ImageSource UploadPhoto
{
get
{
return _UploadPhoto;
}
set
{
_UploadPhoto = value;
RaisePropertyChanged("UploadPhoto");
}
}