title: How to set an Image source to a blank Image control at runtime from selected ListBox Item?
body: <p><strong>PROBLEM:</strong></p>
  
  <p>I have a blank Image control named "<strong>Image1</strong>". </p>
  
  <p>Now, I want to supply a Source to that Image at runtime base on the selected item on my ListBox (ListBoxSource).</p>
  
  <p>How will I do that in "ListBoxSource_SelectionChanged(...)" event?</p>
  
  <pre><code> private void ListBoxSource_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
      {
      //...Some conditional statement in here which determines what image to set or update its Image source
  
          this.Image1.Source = ??? What to supply in here
  
      }
  </code></pre>
  
  <p><strong>NOTE:</strong> I know how to do this using Binding <strong>BUT I know only using another ListBox</strong> to show my selected items. This time I use a <strong>Grid(2 rows and 2 columns:</strong> each cell has a blank Image control in it) for the purpose of supplying each grid cell with the ListBoxSource selected Image item.</p>
  
  <p><strong>OR</strong> Can I use some binding to this using Grid? My other purpose is also to be able to control the Image in different sizes (meaning some image will span rows/columns inside a Grid).</p>
  
  <p>Here is my XAML:</p>
  
  <pre><code> &lt;Window.Resources&gt;
      &lt;DataTemplate x:Key="ItemTemplate"&gt;
          &lt;StackPanel&gt;
              &lt;Image Source="{Binding FileFullName}" HorizontalAlignment="Left" Height="64" Width="64"/&gt;
              &lt;TextBlock Text="{Binding FileName}"/&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}"&gt;
      &lt;ListBox x:Name="ListBoxSource" HorizontalAlignment="Left" ItemTemplate="{DynamicResource ItemTemplate}" ItemsSource="{Binding Collection}" Margin="29,31,0,31" Width="257" SelectionMode="Multiple" SelectionChanged="listBoxSource_SelectionChanged"/&gt;
      &lt;Grid x:Name="GridImageHolder" Height="270" Margin="338,44,0,0" VerticalAlignment="Top" Background="#FFE0D6D6" ShowGridLines="True" DataContext="{Binding SelectedItem, ElementName=listBoxSource}" d:DataContext="{Binding Collection[0]}" HorizontalAlignment="Left" Width="539"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="130"/&gt;
              &lt;RowDefinition Height="140"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="267.883"/&gt;
              &lt;ColumnDefinition Width="271.117"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Image x:Name="Image1" Grid.Row="0" Grid.Column="0" Margin="8,0.96,21.883,8"/&gt;
          &lt;Image x:Name="Image2" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Margin="19.975,0,0,8" Width="218"/&gt;
          &lt;Image x:Name="Image3" Grid.Row="1" Grid.Column="0" Margin="8,21.04,40.883,16"/&gt;
          &lt;Image x:Name="Image4" Grid.Row="1" Grid.Column="1" Margin="8,21.04,33.117,16" /&gt;
  
      &lt;/Grid&gt;
  
  &lt;/Grid&gt;
  </code></pre>