programming, .NET, linux and others

WPF: Use a resource image from XAML

by Gregor Uhlenheuer on October 6, 2011

Since I always forget how to reference a resource image file from inside a XAML file I will quickly describe how it can be done.

Say you have added an existing image file to your a project with the namespace Project.Tools. Now all you have to do is to set the Build Action of the file to Resource and reference the image like the following:

    <Image Source="/Project.Tools;component/Resources/Images/image.png" Height="16" Width="16"/>

In the example above the image is located inside the project in a directory structure of /Resources/Images/.


This post is tagged with wpf, xaml and .net