NTDeveloper

I have an icon that is an embedded resource in an external assembly. I load the resource stream (successfully) via the usual manner:

Code Snippet

Stream stm = assembly.GetManifestResourceStream("resourcePath.ResourceName.ico");

I assign this stream to a newly-created bitmap image:

Code Snippet

BitmapImage img = new BitmapImage();

img.StreamSource = stm;

I then assign the bitmap image to the icon property of a WPF window:

Code Snippet

myWindow.Icon = img;

I am then rewarded with the exception: "Image Source For Icon Property Must Be an Icon File".

Anyone know what is going on

Thanks.



Re: Windows Presentation Foundation (WPF) Image Source For Icon Property Must Be an Icon File

Ryan Lamansky / Kardax

I think you have to use BitmapFrame.Create to get something that the Icon property will accept.

I agree that it's stupid that it's so picky Smile

-Ryan / Kardax





Re: Windows Presentation Foundation (WPF) Image Source For Icon Property Must Be an Icon File

NTDeveloper

Yep, that's what I ended up doing; seems that the way I first attempted to do it should also work though...