问题描述
在 .xaml 中
<Image x:Name="image">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="GetimageLocationFromExternalCard"/>
</Image.GestureRecognizers>
</Image>
<Label x:Name="fileLocation"/>
在 .xaml.cs 中
private void GetimageLocationFromExternalCard(object sender,EventArgs e)
{
// what can i write is here
image.source = fileLocation.Text;
}
我想做的就像从存储卡中选择一个图像文件并作为字符串位置发送到标签文本。
解决方法
var photo = await MediaPicker.PickPhotoAsync();
image.Source = photo.FullPath;