在Windows-Phone-7中如何从C#中的sender参数获取对象

在Windows-Phone-7中如何从C#中的sender参数获取对象,c#,windows-phone-7,sender,C#,Windows Phone 7,Sender,我想通过单击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 MouseButtonEvent

我想通过单击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());
}
请给我一些想法,我如何才能得到我的图像控制的来源。
提前感谢

您需要将
Image.Source
转换为
System.Windows.Media.Imaging.bitmap图像
,才能获取您的
UriSource

MessageBox.Show(((System.Windows.Media.Imaging.BitmapImage)image.Source).UriSource.ToString());

为什么不起作用?发生了什么事?这件事怎么办?说它是windows-phone-7app@SLaks&CC lnc:不,它不起作用。它会给出类似“System.Windows.Media.Imaging.BitmapImage”的输出@DebobrotoDas:谢谢,但它对methanks Mark没有用处,但我不知道如何转换。可以举个小例子吗?@ankit不客气,无论何时,只要像这样返回类型名称,您都需要将对象强制转换为该类型以获取其属性。