I have an image control in one of my app implementation using xamarin forms (2.0), which is binded to an ImageSource
XAML Code:
<Image x:Name="MyPhoto" Grid.Row="0"
Grid.Column="0"
Aspect="AspectFit"
Source="{Binding ImageSource3}"
VerticalOptions="CenterAndExpand" WidthRequest="125" >
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding SelectPictureCommand}" />
</Image.GestureRecognizers>
</Image>
When, I tap on the image, it opens the photo album to pick a photo (using xam media plugin). I am able to successfully select the picture. The problem is that the image appears for a split of second in the image control and then it disappears. The same code works well in a different form in the same project. Also this works well in android but gives issue in ios . I am testing using iPhone.
ViewModel Code:
private async Task SelectPicture()
{
try
{
var file = await CrossMedia.Current.PickPhotoAsync(); //using xam media plugin
ImageSource3 = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
stream.Position = 0;
file.Dispose();
return stream;
});
mediaFilePath = file.Path;
uploadImage = true;
}
catch (System.Exception ex)
{
}
}
Any help would be appreciable!