title: WPF Image Source binding with StringFormat
body: <p>I'm new to WPF and MVVM (started this week experimenting with it) and trying to bind image resources at runtime. The items I'm trying to display contain an enumerate property that indicates the type or state of the item:</p>
  
  <pre><code>public class TraceEvent
  {
      /// &lt;summary&gt;
      /// Gets or sets the type of the event.
      /// &lt;/summary&gt;
      /// &lt;value&gt;The type of the event.&lt;/value&gt;
      public TraceEventType EventType { get; set; }
  }
  </code></pre>
  
  <p>As far as I known the Source attribute of Image has a value converter that takes strings and returns Uri objects.</p>
  
  <pre><code>&lt;Image Source="{Binding Path=EventType, StringFormat={}/AssemblyName;component/Images/{0}Icon.ico}" /&gt;
  </code></pre>
  
  <p>So why doesn't the above work? If I enter the uri directly (without binding) the image is shown perfectly. In fact, if I do the binding in a TextBlock and use the result of that value in the Image also shown without problem:</p>
  
  <pre><code>&lt;TextBlock Visibility="Collapsed" Name="bindingFix" Text="{Binding Path=EventType, StringFormat={}/AssemblyName;component/Images/{0}Icon.ico}"/&gt;
  &lt;Image Source="{Binding ElementName=bindingFix, Path=Text}" /&gt;  
  </code></pre>
  
  <p>I'm pretty sure I'm doing something terrible wrong for such an obvious thing to do with images. </p>
  
  <p>Thanks.</p>