首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Windows-Phone-7中从C#的发送者参数中获取对象

如何在Windows-Phone-7中从C#的发送者参数中获取对象
EN

Stack Overflow用户
提问于 2012-11-29 12:15:53
回答 1查看 1.5K关注 0票数 0

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

代码语言:javascript
复制
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());
}

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-29 12:42:33

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

代码语言:javascript
复制
MessageBox.Show(((System.Windows.Media.Imaging.BitmapImage)image.Source).UriSource.ToString());
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13618747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档