title: WPF: ListView with Images from a folder
body: <p>I'm sort of new to WPF, but I have to do this and it's taking a lot of my time. I've searched for a solution but there are many alternative solutions and I honestly don't understand most of this. I have this XAML code:</p>
  
  <pre><code>&lt;ListView Name="Thumbnails"&gt;
      &lt;ListView.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Image Source="{Binding}" Height="30" Width="30" Margin="5"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListView.ItemTemplate&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>As well as this codebehind:</p>
  
  <pre><code>private void Window_Loaded(object sender, RoutedEventArgs e)
  {
      DirectoryInfo folder = new DirectoryInfo(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\SlikeSportista\");
      FileInfo[] images = folder.GetFiles("*.jpg");
      foreach (FileInfo img in images)
      {
          Thumbnails.Items.Add(img);
      }
  }
  </code></pre>
  
  <p>I've also tried this line of code in the foreach loop:</p>
  
  <pre><code>Thumbnails.Items.Add(System.Drawing.Image.FromFile(img.FullName));
  </code></pre>
  
  <p>In both cases the items are added, but the images are not displayed correctly, or rather, at all. You can select them, and there are the same amount of elements as there are in the folder, but there is no display.</p>
  
  <p>Another question (less important one) would be how to display the images in squares instead of rows. Basically I want to have about 4 or so images per row, but now I have only 1 element per row, stretched all the way (although I can't see what is being displayed).</p>