title: WPF Image Source Binding
body: <p>I have a <code>ListBox</code> with <code>ItemTemplate</code>s and some data bindings, including an Image.</p>
  
  <p>The <code>ItemsSource</code> is set in the codebehind. Everything works as expected until the app tries to change the image's source by updating the object's member, which is bound to the image source. What am I doing wrong?</p>
  
  <p>Here's the XAML:</p>
  
  <pre><code>&lt;ListBox x:Name="myList" MouseDoubleClick="myList_MouseDoubleClick" ScrollViewer.VerticalScrollBarVisibility="Disabled"&gt;
      &lt;ListBox.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;WrapPanel Orientation="Vertical" /&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ListBox.ItemsPanel&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Border BorderBrush="DarkGray" BorderThickness="1"&gt;
                  &lt;StackPanel Orientation="Horizontal" Width="100"&gt;
                      &lt;Image Width="38" Height="38" Source="{Binding Path=icon}" /&gt;
                      &lt;StackPanel Width="100"&gt;
                          &lt;Label Content="{Binding Path=name}" /&gt;
                          &lt;Label Content="{Binding Path=state}" /&gt;
                      &lt;/StackPanel&gt;
                  &lt;/StackPanel&gt;
              &lt;/Border&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Some parts of the codebehind:</p>
  
  <p>In <code>Window_Initialized</code>:</p>
  
  <pre><code>myList.ItemsSource = myLineList;
  </code></pre>
  
  <p>In <code>myList_MouseDoubleClick</code>:</p>
  
  <pre><code>Line aLine = myList.SelectedItem as Line;
  if (aLine != null) {
    aLine.icon = "idle.jpg";
  }
  </code></pre>