0
我試圖添加一個圖片從我的手機庫,但不斷得到一個System.Reference,我想從按鈕上按一下我的手機圖庫上傳圖像,它給出了一個nullReferenceException DependencyService。Xamarin Forms DependencyService nullReferenceException
我的頁面:
InitializeComponent();
Device.OnPlatform(
Android:() => {
new Thickness(0, 20, 0, 0);
}
);
Image image = new Image();
Button addImage = new Button { Text = "Select Image" };
addImage.Clicked += (sender, args) =>
{
IGalleryImageService galleryService = DependencyService.Get<IGalleryImageService>();
galleryService.ImageSelected += (o, imageSourceEventArgs) => image.Source = imageSourceEventArgs.ImageSource;
galleryService.SelectImage();
};
this.Content = new StackLayout
{
Children =
{
image,
addImage
}
};
是的,那就是問題所在。 謝謝! – Sylar