在Windows Phone 8上我有一个从图像库中获取图像的功能,应该将其作为基本字符串发送到服务器但是当调用选择图像时,它会将我转移到库页面,但不要等到我选择它继续发送将数据清空到服务器。
public void Chplaceimg(string PlaceID)
{
YOimage changeplaceimg = new YOimage();
if (changeplaceimg.pickImage() != null)
{
var pairs = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string> ("id", _id),
new KeyValuePair<string, string> ("image", changeplaceimg._base64Image),
new KeyValuePair<string, string> ("place", PlaceID)
};
var serverData = serverConnection.connect("image.php", pairs);
}
}
public bool pickImage()
{
var photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += PhotoChooserTaskCompleted;
photoChooserTask.Show();
return true;
}
//run function convertToBase64 when an image is choosed
private void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
convertToBase64(e);
}
}
答案 0 :(得分:0)
您必须作为PhotoChooserTaskCompleted
回调的一部分进行服务呼叫。
//run function convertToBase64 when an image is choosed
private void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
// send data to server here
convertToBase64(e);
}
}