title: How do I limit the Image size to its parent container
body: <p>I am doing my first WPF-Project with the MVVM-Model. I have got two views that i want to look like that:</p>
  
  <p><img src="https://i.stack.imgur.com/SqQ8T.png" alt="Thats what it should look like"></p>
  
  <p>But sadly the images do not shrink to parent size, they stay in original size:</p>
  
  <p><img src="https://i.stack.imgur.com/lpErt.png" alt="Thats what it does look like"></p>
  
  <p>Views.PictureList</p>
  
  <pre><code>&lt;UserControl x:Class="BIF.Views.PictureList"
           xmlns:view="clr-namespace:BIF.Views"
           d:DesignHeight="120" d:DesignWidth="300"&gt;
  
      &lt;ListBox ItemsSource="{Binding List}" &lt;!-- List&lt;PictureViewModel&gt; --&gt;
          ScrollViewer.VerticalScrollBarVisibility="Hidden" 
          SelectedItem="{Binding CurrentPicture, Mode=TwoWay}" SelectionMode="Single"&gt;
          &lt;ListBox.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;StackPanel Orientation="Horizontal" /&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ListBox.ItemsPanel&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;ListBoxItem&gt;
                      &lt;view:Picture DataContext="{Binding}" /&gt;
                  &lt;/ListBoxItem&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Views.Picture</p>
  
  <pre><code>&lt;UserControl x:Class="BIF.Views.Picture"
           d:DesignHeight="200" d:DesignWidth="200"&gt;
      &lt;Border BorderBrush="Black" BorderThickness="1" CornerRadius="4"&gt;
          &lt;Image Source="{Binding FilePath}"/&gt;
      &lt;/Border&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>I have already tried to set height of view:Picture manualy by adding:</p>
  
  <pre><code>Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type StackPanel}}, Path=ActualHeight}"
  </code></pre>
  
  <p>But thats not working 100% correct and I also do not want to set a fix height, because I want the PictureList to be resizeable.</p>
  
  <p>Any suggestions are welcome.</p>