Windows phone 7.1 从.cs文件更改图像源
如何从.cs文件更改图像的当前源?我试过这个: file.xaml.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文件中有一个控件。我现在让它工作起来了。我将图像的“构建操作”更改为“内容”,因为图像是项目的本地图像,
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
这应该可以工作-假设图像存在于指定的位置。到底发生了什么?