How to set XAML window icon

I have a SOLIDWORKS add-in, which creates a new window. I would like to set the icon for this window. How do I do that, either in XAML or in code-behind?

My image is a .ICO file or PNG. All examples I could find use ICO files. I've set the images as an embedded resource and it copies to the output folder. Yet I keep getting IO exceptions, without those telling me the exact path they are trying to find.

I've tried it in XAML:

Icon="/CADBooster.Tool.Addin;component/icon.ico">

or 


I've tried the code-behind:

var iconUri = new Uri("/CADBooster.Tool.Addin;component/icon.ico", UriKind.RelativeOrAbsolute);
Icon = BitmapFrame.Create(iconUri);

I've also tried the format pack://application,,,/CADBooster.Tool.Addin;component 

Any ideas?

SolidworksApi/macros