2013-04-15 48 views
0

我试过这个,但我没有得到答案。我有3个图像框。在这2个图像框中有图像,1个图像框是空的。现在我想改变image_tab事件上的图像,任何人都可以帮我找到这个?如何获得Windows Phone 7中image_tab上的图像路径

Uri myfile = new Uri("Images/star.png", UriKind.Relative); 
StreamResourceInfo resourceInfo = Application.GetResourceStream(myfile); 
BitmapImage myimage = new BitmapImage(myfile); 
myimage.SetSource(resourceInfo.Stream); 
image1.Source = myimage; 

回答

0

我不知道究竟image_tab你的情况,但你可以通过使用简化图像源分配(也许Image_Tap):

Uri uri = new Uri("PATH", UriKind.Relative); 
BitmapImage imageSource = new BitmapImage(uri); 
image.Source = imageSource; 

记住,该ImageSource对象不直接公开路径,所以你可能想要有一个内部参考位置来处理你使用的文件的路径。

+0

是它在Image_Tap上,我也试过这一个,但我没有得到答案,我只想获得该图像的路径,我想存储在一个字符串变量,可以帮助找到这个(对不起我的英语不好) – John

+0

我找到答案..答案是String'imagesource =((BitmapImage)image.Source).UriSource.ToString();' – John