Setting Icon for wpf application (VS 08)
Assuming you use VS Express and C#. The icon is set in the project properties page. To open it right click on the project name in the solution explorer. in the page that opens, there is an Application tab, in this tab you can set the icon.
@742's answer works pretty well, but as outlined in the comments when running from the VS debugger the generic icon is still shown.
If you want to have your icon even when you're pressing F5, you can add in the Main Window:
<Window x:Class="myClass"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Icon="./Resources/Icon/myIcon.png">
where you indicate the path to your icon (the icon can be *.png
, *.ico
.)
(Note you will still need to set the Application Icon or it'll still be the default in Explorer).
Note: (replace file.ico with your actual icon filename)
- Add the icon to the project with build action of "Resource".
- In the Project Properties, set the Application Icon to file.ico
- In the main Window XAML set:
Icon=".\file.ico"
on the Window
After getting a XamlParseException with message: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' with the given solutions, setting the icon programmatically worked for me. This is how I did it:
- Put the icon in a folder <icon_path> in the project directory
- Mimic the folder path <icon_path> in the solution
- Add a new item (your icon) in the solution folder you created
- Add the following code in the WPF window's code behind:
Icon = new BitmapImage(new Uri("<icon_path>", UriKind.Relative));
Please inform me if you have any difficulties implementing this solution so I can help.