Tuesday, October 6, 2015

ICO files in WPF applications

Well the last blog entry was a bit lengthy so here's a nice short one. Is has to do with assigning a ico file to a WPF project. The ico file contains a set of graphics at different resolutions in a single file and is used by WPF for the taskbar, the alt-tab, and window graphics like this...




Setting the ico file is simple. You add it to your project and reference it in the project properties under the application tab like this.

Setting the ico file for a WPF project
The problem is that when you are debugging in visual studio the ico file is not used because you are actually running against a proxy exe called vshost.exe. If this is a problem for you there are two solutions.


  1. Disable the visual studio hosting process in the debug tab of the project properties. This causes you to debug against the actual executable that has the ico file. I don't know why the proxy doesn't have it.
  2. Explicitly specify the ico file in the main page XAML like this.
    <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Icon="Images\pur.ico" .../>
  Take your pick.

No comments:

Post a Comment