0

我想通过单击我的 wp7 应用程序中的图像来获取图像控件的来源,我尝试了这个但没有得到解决方案。

Image img = new Image();
img.Source = new BitmapImage(uri);
img.Height = 105;
img.Width = 167;
img.Margin = new Thickness(Xpos, Ypos, 0, 0);
//img.Height = j;
img.MouseLeftButtonUp += new MouseButtonEventHandler(img_MouseLeftButtonUp);

void img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
     var image = (Image)sender;
     MessageBox.Show(image.Source.ToString());
}

请给我一些想法,我怎样才能获得我的图像控制的来源。提前致谢

4

1 回答 1

0

您需要将 转换Image.Source为 aSystem.Windows.Media.Imaging.BitmapImage才能获得UriSource.

MessageBox.Show(((System.Windows.Media.Imaging.BitmapImage)image.Source).UriSource.ToString());
于 2012-11-29T04:42:32.843 回答