MediaPlugin (https://github.com/jamesmontemagno/MediaPlugin)과 함께 Xamarin Forms PCL (MVVM Prism)을 사용하고 있습니다. 내가 속성을 IMAGEPATH하기 (웹에서) 이미지의 URL을 설정Media.Plugin이있는 Xamarin Forms MVVM (Prism) - 장치 저장 장치에서 사진을 가져 오는 방법
<Image Source="{Binding ImagePath}" HeightRequest="100" WidthRequest="100"/>
, 그것은 작동합니다
나는 내가 가진 내 XAML에서 ImagePath를
private string imagePath;
public string ImagePath
{
get { return imagePath; }
set { SetProperty(ref imagePath, value, "ImagePath"); }
}
라는 공용 속성을 가진 뷰 모델을 문제없이.
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});
ImagePath = file.Path;
// also tried: ImagePath = ImageSource.FromFile(file.Path).toString();
file.Path가 같은 값을받는 VAR : 나는 다음과 같은 코드 (MediaPlugin)를 사용하여 사진을 찍을 때,
그러나 ("http://www.myaddress.com/myimage.jpg"나는이 같은 문자열을 설정하고있다) 이 :이 file.Path 가치있는와
"/storage/emulated/0/Android/data/{APPNAME}.Android/files/Pictures/{DIRECTORYNAME}/{IMAGENAME}"
전자 그럼 ImagePath 속성을 설정 해요 : ImagePath = file.Path;
그러나 촬영 한 이미지가 화면에 나타나지 않습니다.
또한 MediaPlugin 문서에서 제안한대로 Image.Source 속성을 사용하려고했지만 원하는 결과에 도달하지 못했습니다. VM에
Public 속성 :
은 또한 다음을 시도
private Image image = new Image();
public Image Image
{
get { return image; }
set { SetProperty(ref image, value, "Image"); }
}
XAML을 :
<Image Source="{Binding Image.Source}" HeightRequest="100" WidthRequest="100"/>
후 설정 파일의 값 (전 켰을 때) :
image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});
거기에 있습니까? 어떻게 작동하게 할 수 있습니까? 감사합니다.
위대한, 그것은 일했습니다! 이 ImageSource 유형을 SQL 데이터베이스에 게시 할 tib이 있습니까? 또는 파일을 저장하고 업로드하는 것이 더 좋을까요? – user3814711
IncidentImage 유형을 로컬 Sqlite 데이터베이스에 저장하고 REST API 서비스를 통해 업로드합니다. –