Windows phone 7 使用PhotoChooserTask向按钮添加背景图像
我正试图通过photochoosertask在按钮中插入图像 但在将btnSelectImage.Content强制转换为图像时,它会给出空值 你能帮帮我吗Windows phone 7 使用PhotoChooserTask向按钮添加背景图像,windows-phone-7,Windows Phone 7,我正试图通过photochoosertask在按钮中插入图像 但在将btnSelectImage.Content强制转换为图像时,它会给出空值 你能帮帮我吗 void photoChooserTask_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { if (e.TaskResult == TaskResult.OK) { Image contentIma
void photoChooserTask_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
Image contentImage = btnSelectImage.Content as Image;
if (contentImage != null)
{
contentImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(e.OriginalFileName));
}
}
}
试试这个
我不确定你的xaml是什么样子。你必须这样使用它
<Button>
<Image x:Name="contentImage" />
</Button>
问题是-contentImage即将为空
<Button>
<Image x:Name="contentImage" />
</Button>