I need to assign an Icon
to a WPF window, but cannot seem to do this from a resource file. I tried this solution, but end up with:
ImageSource for Icon property must be an icon file
But, if I try to leave it as Icon
, then I get an error that I need to convert to ImageSource
...
Icon = Properties.Resources.myIcon.ToImageSource();
I ended up doing the following:
using (var iconStream = new MemoryStream())
{
icon.Save(iconStream);
iconStream.Seek(0, SeekOrigin.Begin);
return BitmapFrame.Create(iconStream);
}
which was actually one of the unaccepted answers from the same question I already referenced: just a different response