Using Feb. CTP:
I have a WinFX control library which contains various Window objects. The project layout looks like this:
- DefaultUI.csproj
- LoginScreen
- LoginScreen.xaml (Window)
- Images
- icon.ico (Resource)
Unfortunatly, I can't figure out how to specify the Window's Icon property in XAML. In other control libraries I was able to use Icon="/Images/icon.ico" and it would work; however, in this particular project that fails with a BamlParseException in InitializeComponent:
"Error at element 'LoginScreen' in markup file 'DefaultUI;component/loginscreen/loginscreen.xaml' : '/Images/icon.ico' string is not a valid value for 'Icon' property of type 'ImageSource'."
I have tried /Images/icon.ico, Images/icon.ico, pack://application:,,,/Images/icon.ico, and pack://siteoforigin:,,,/Images/icon.ico - all fail in the same way. I've also tried including the icon as Content instead of Resource, no luck.
It's not just the icon behaving this way, there is another image included in that project and trying to reference it fails as well.

Specifying Window icon via string isn't working
Ian Waters
Elijah
Theres another thread with the same issue which might be of help
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=524852&SiteID=1
DarkOasis
I code a game named zyDefender (I think I'll change the name, "Windows Defender" didn't exist when I had the idea, or I didn't know it). The funny thing is that I compiled and used the code successfully 2 das ago. Yesterday I tried to run my game again after making a few changes of the game logic (not the UI). Now I allways get an exception telling that my string is not a valid value for the Icon property of type ImageSource.
The Icon is an ico-File Defender.ico added to the Solution in a new folder called Images.
I tried the following strings in the Icon property of the Window:
Defender.ico
Images/Defender.ico
/Images/Defender.ico
/zyDefender;component/Images/Defender.ico
/zyDefender;Images/Defender.ico
zyDefender;component/Images/Defender.ico
zyDefender;Images/Defender.ico
zyDefender/Images/Defender.ico
allways the same exception :(
trulyviral
you might be hitting this issue
http://msdn.microsoft.com/windowsvista/support/relnotes/netfxjunectp/default.aspx#topic2
Ashwin Panse - MSFT
So I removed it and I can run my game successfully.
Amorano
When you add a leading slash to a relative Uri, you're effectively saying "look for this file relative to the application".
I'm assuming the icon is embedded into the library (i.e. declared as Resource in the library's project file). In that case, the sure fire way of referencing it is using a relative Uri like "/DefaultUI;component/Images/icon.ico". Here you're saying "look for a reference library DefaultUI.dll relative to the application and then look for icon.ico in the Images folder inside it". Such a reference will work when made from a XAML inside the library or inside the application which has the aforementioned library as reference assembly. Hope that helps.
ramkanna