2013-04-15 47 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