Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7.1 从.cs文件更改图像源_Windows Phone 7.1_Windows Phone 7 - Fatal编程技术网

Windows phone 7.1 从.cs文件更改图像源

Windows phone 7.1 从.cs文件更改图像源,windows-phone-7.1,windows-phone-7,Windows Phone 7.1,Windows Phone 7,如何从.cs文件更改图像的当前源?我试过这个: file.xaml.cs: BitmapImage yesImage = new BitmapImage(new Uri("/Test;component/Images/yes.png")); // new source address img.Source = yesImage; // update source of img xaml文件中有一个控件。我现在让它工作起来了。我将图像的“构建操作”更改为“内容”,因为图像是项目的本地图像,

如何从.cs文件更改图像的当前源?我试过这个:

file.xaml.cs:

BitmapImage yesImage = new BitmapImage(new Uri("/Test;component/Images/yes.png")); // new source address   
img.Source = yesImage; // update source of img

xaml文件中有一个控件

我现在让它工作起来了。我将图像的“构建操作”更改为“内容”,因为图像是项目的本地图像,所以我删除了“/Test;component/”,并添加了UriKind.Relative到URI对象

BitmapImage yesImage = new BitmapImage(
       new Uri("/Images/yes.png", UriKind.Relative)); // new source address
img.Source = yesImage; // update source of img

这应该可以工作-假设图像存在于指定的位置。到底发生了什么?