【发布时间】:2010-10-14 00:44:50
【问题描述】:
大家好,
感谢您阅读和分享任何见解。我创建了一个新的简单 Windows Phone 7 应用程序。我想用各种 .png 文件更新表单上有两个 Image 对象。我已将 .png 文件包含到我的项目中,并且我相信我正在构建指向这些文件的正确 URi 资源。
Uri myImage1URi = new Uri( strImage1, UriKind.RelativeOrAbsolute );
Uri myImage2URi = new Uri( strImage2, UriKind.RelativeOrAbsolute );
System.Windows.Media.Imaging.BitmapImage bi1 = new System.Windows.Media.Imaging.BitmapImage(myImage1URi);
System.Windows.Media.Imaging.BitmapImage bi2 = new System.Windows.Media.Imaging.BitmapImage(myImage2URi);
image1.Source = bi1;
image1.Stretch = Stretch.Fill;
image2.Source = bi2;
image2.Stretch = Stretch.Fill;
仅此一项并不能完成我想要的(将图像更新为来自 URi 的两个)。
我知道发生了一些事情(即:我正在做一些愚蠢的事情),因为所有 BitmapImage 类描述都提到我必须在使用 BitmapImage 对象之前执行一个 .BeginInit() ,并且之后调用 .EndInit() 。这些方法调用对我不起作用,所以我知道有些不对劲......
或者也许我完全不在基地,我只是需要一种方法来告诉我的主窗口重新绘制自己?我也有过这样的想法。
再次感谢。
【问题讨论】:
标签: c# .net windows windows-phone-7