Skip to main content
 首页 » 编程设计

c#之BitmapImage 缺少 BeginInit() 和 EndInit() 函数

2024年01月01日35kerrycode

正如我所发现的,我似乎无法访问上述功能。我正在从中导入 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 操作系统设置为 8(我假设它使用 .NET 4.5)

请您参考如下方法:

这是 Windows Phone version of BitmapImage .查找类的 Windows Phone 版本等可能有点困惑 - 我通常从 dev.windowsphone.com 进行搜索并将结果限制为“图书馆”。