BitmapImage missing BeginInit() and EndInit() function?

随声附和 提交于 2019-12-14 03:57:15

问题


As I have discovered, I do not seem to have access to the mentioned functions. I am importing the BitmapImage class from

 using System.Windows.Media.Imaging;

however in the following code:

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..]
}

I get a parser error and a build error on the src.BeginInit() function. I seem to also be missing the EndInit() function and probably more functions inside that class. I have consulted the documentation to see if I screwed up the import or am refering to some other class, but as far as I can see I am referring to the correct class. (hovering over it reveals it is referring to System.Windows.Media.Imaging.BitmapImage class)

Any ideas on what might be going on? Any help is greatly appreciated please let me know if more information is necessary!

Refereed documentation: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx

Windows Phone OS is set to 8 (I assume it uses .NET 4.5)


回答1:


Here's the Windows Phone version of BitmapImage. It can be a bit confusing to find the Windows Phone versions of classes, etc. - I usually do a search from dev.windowsphone.com and limit the results to "Library".



来源:https://stackoverflow.com/questions/13893837/bitmapimage-missing-begininit-and-endinit-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!