【发布时间】:2020-12-22 20:57:39
【问题描述】:
我正在尝试从图库中挑选一张图片,并且我已经完成了this doc 中的所有内容,但我的 .cs 实现中的“图片”对象出现错误。
我的 .cs 代码:
public partial class MyProfilePage : ContentPage
{
public MyProfilePage()
{
InitializeComponent();
BindingContext = new MyProfileViewModel();
}
async void ImageButton_Clicked(object sender, EventArgs e)
{
//(sender as Button).IsEnabled = true;
Stream stream = await DependencyService.Get<IPhotoPickerService>().GetImageStreamAsync();
if (stream != null)
{
image = ImageSource.FromStream(() => stream);
}
(sender as Button).IsEnabled = true;
}
}
【问题讨论】:
-
首先,“错误”是什么意思?告诉我们具体错误是什么以及它发生在哪一行将是非常有用的信息。 2、尝试使用 Xamarin Forms 的媒体插件而不是这种方法
标签: c# image xamarin xamarin.forms gallery