Lesson 04.1: Creating the Location class

In this lesson, we will create a class to hold the Location information (including a graphic file to display).




To add an image to your project:

  • Create the image in your preferred graphics program.
  • Add the file to the project, as an existing item.
  • Set the image’s “Build Action” property to “Resource”
  • When displaying the file, you will need to include the assembly (project) name where the file is located, along with the path (folders) to the image file.
    • For this project, it will be “/Engine;component/Image/Locations/Home.png” (for the Home location image).


Image Files

All image files, in a zip file

Or, download the individual images (right-click, and save to your disk):

Source Code







Return to main page

4 thoughts on “Lesson 04.1: Creating the Location class

  1. Hi Scott,

    Just a comment – when adding the images and changing the Build Action from Content to Resource, you can select all the images in the Solution Explorer at once and change them all at once, rather than clicking each one and changing it individually.

    To select multiple items:
    1> click on the first one, and hold Shift down and click on the last one, to highlight all the items
    2> Also, individual items can be added or removed from the highlighted list by holding down Ctrl and clicking.
    3> Once the desired list of all items is selected, in the properties window, change Build Action just like you would for a single item, but it will change it for all highlighted items.

    I think this is good to point out because it can be applied to any objects in the solution that need to have their properties updated to the same thing.

    1. Yes. This is especially useful when working on Windows Forms programs, when you want to change some properties for many textboxes/labels/buttons. It makes setting height/width/alignment/etc. much faster than individually clicking on each one.

  2. Hi Scott,

    Thanks for these tutorials!

    Can you explain why the “;component” is needed after “/Engine” in the Image path?

    1. You’re welcome, Mike.

      If you want one project (WPFUI) to use a resource (image) from another project (Engine), you need to include “;component”. If the resource is in the same project/assembly, you do not need to include “;component”.

      There is some more information on this at: Microsoft documentation

Leave a Reply

Your email address will not be published. Required fields are marked *