【发布时间】:2012-12-15 16:10:32
【问题描述】:
正如我所发现的,我似乎无法使用上述功能。我正在从
导入 BitmapImage 类 using System.Windows.Media.Imaging;
但是在下面的代码中:
public static void loadCardImage(Card card, ref Image image)
{
BitmapImage src = new BitmapImage();
src.BeginInit(); <--Cannot find this function
src.UriSource = new Uri(card.imageLink, UriKind.Relative); <-- this is fine
[..NotFinishedCoding..]
}
我在 src.BeginInit() 函数上收到解析器错误和构建错误。我似乎也缺少 EndInit() 函数以及该类中的更多函数。我已经查阅了文档,看看我是否搞砸了导入或引用了其他类,但据我所知,我指的是正确的类。 (悬停在它上面显示它指的是 System.Windows.Media.Imaging.BitmapImage 类)
对可能发生的事情有任何想法吗?非常感谢任何帮助,如果需要更多信息,请告诉我!
参考文档:http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx
Windows Phone OS 设置为 8(我假设它使用 .NET 4.5)
【问题讨论】:
-
只要不需要设置
CacheOptions或CreateOptions之类的属性,就不需要使用BeginInit和EndInit。只需在 WPF 中使用BitmapImage constructor with Uri parameter。
标签: c# xaml windows-phone