Xamarin通过Media.Plugin形成MVVM(Prism)-如何从设备Camera获取拍摄的图片

问题描述 投票:0回答:2
How to take a picture by the camera and show in display before saving data.....

在页面上..

    <Image Source="{Binding ImageTakeFile2.source}" Grid.Column="0" WidthRequest="100" HeightRequest="100" HorizontalOptions="Start"/>

在ViewModel中。

private MediaFile _photo;
 _photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
        { Directory = "Sample", Name = "test.jpg", PhotoSize = PhotoSize.MaxWidthHeight, MaxWidthHeight = imageSize });


ImageTakeFile2.Source = ImageSource.FromStream(() =>
     {
         var stream = _photo.GetStream();
         return stream;
     });
xamarin.forms xamarin.android prism
2个回答
1
投票
用途:

ImageTakeFile2.Source = ImageSource.FromFile(_photo.Path);


0
投票
我喜欢这种方式.....
© www.soinside.com 2019 - 2024. All rights reserved.