[英]Why am I unable to obtain an image from the stream in xamarin forms?
var image = await PicturePicker.PickImage();
Image img = ImageSource.FromStream(image);
My code is as shown above. 我的代码如上所示。 image is a stream returned from the picture picker and i fed it to the FromStream function in xamarin forms but it thorws me the following error Argument type 'System.IO.Stream'is not assignable to parameter type System.Func 图像是从图片选择器返回的流,我将其馈送到xamarin形式的FromStream函数中,但它使我感到以下错误参数类型'System.IO.Stream'不能分配给参数类型System.Func
Any kind soul able to help me out with this? 有什么好心的人可以帮我这个忙吗?
I think instead of Image img. 我认为不是Image img。 You should use ImageSource img 您应该使用ImageSource img
public ImageSource Imgsrc;
and try this code 并尝试此代码
Imgsrc = ImageSource.FromStream(() =>
{
return image;
});
Actually this is how I do to load the images to my ViewModel.Hope it helps 其实这就是我将图像加载到ViewModel的方法。希望对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.