WPF: Selecting a Background Image

As many people have pointed out, WPF in its current form is far from point-and-click experience. This is how you set background image on a windows form (not WPF):

  1. Select the form
  2. Right click on properties
  3. Find BackgroundImage property
  4. Click “Import”, find your file on disk
  5. You’re done

In WPF you need to add the file to the project, and then you have to write by hand something like this:

<Window.Background>
  <ImageBrush ImageSource="/Images/sahara.jpg" Stretch="Fill" />
</Window.Background>

This is way too much writing. I would tolerate something like <Window BackgroundImage="/Images/sahara.jpg">, but this brush mambo-jumbo just does not feel right. Too much noise. Yes, I know it fits nicely in the conceptual model et cetera, but it is still too much typing for such a simple task.

Posted in

Leave a Reply

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