Skip to content

How to add an image to your project

Why this approach?

There are many ways to add images to a project.
The thing I provide you below, is just the way, I do it and it works pretty fine ♥️

Step-by-step

  1. Create a folder named Images inside the Themes directory.
  2. Copy the image you want to use into the newly created folder.
  3. Right-click the image file and set:
    • Build ActionResource
  4. Reference the image in XAML using a pack URI:
xml
<Image
    Source="pack://application:,,,/LoginRegisterLibrary;component/Themes/Images/example.png" />

Rotating an image in WPF

To rotate an image in WPF, you use a RenderTransform with a RotateTransform.
This allows the image to rotate dynamically without affecting layout.

xml
<!--Little example, rotate 45° -->
<Image Source="needle.png">
    <Image.RenderTransform>
        <RotateTransform Angle="45" />
    </Image.RenderTransform>
</Image>