title: How to bind the Image.Source in MVVM correctly?
body: <p>I spent some time now trying to work this out but I am still stuck on it. I have a WPF application with a MVVM pattern. In my ViewModel I have three cases where:</p>
  
  <ul>
  <li><code>X needs Y</code> and <code>Y is available</code></li>
  <li><code>X needs Y</code> and <code>Y is not available</code></li>
  <li><code>X doesn't need Y</code></li>
  </ul>
  
  <p>I am trying to set an image icon on my view based on these conditions (Like a Check Mark, exclamation Mark... whatever).</p>
  
  <p><strong>In ViewModel:</strong>
  I created my properties. On any GUI change, I set the variables based on the above cases similar to the following:</p>
  
  <pre><code>void MyBigFunctionToSetAllProperties()
  {
     // other cases
     // ..
     if (NeedsY &amp;&amp; YExists)
      {
          // properties
          StatusIconPath = "@\"/Resources/SessionView/X-With-Green-Check-White.png\"";
          ResultIconPath = "@\"/Resources/SessionView/Y-White.png\"";
      }
  }
  </code></pre>
  
  <p>In <strong>View.Cs</strong>: I did literally nothing.</p>
  
  <p>In <strong>View.xaml:</strong> I bind like this:</p>
  
  <pre><code>&lt;StackPanel&gt;
       &lt;Image Source="{Binding StatusIconPath} /&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>I still can't see why it is not working. What is that thing that I am missing? Please and thanks.</p>
  
  <p>It did not work to bind the properties directly with the Xaml as recommended. I tried it this way:</p>
  
  <p><strong>VM:</strong> sample property:</p>
  
  <p><code>public BitmapImage VerificationStatusIcon{ get { return new BitmapImage(new Uri(@VerificationStatusIconPath, UriKind.Relative));}}</code></p>
  
  <p><strong>View Xaml</strong>:</p>
  
  <pre><code>&lt;Image Name="verificationStatusImage" Source="{Binding VerificationStatusIcon}" Margin="5,0" Width="40" Height="40"/&gt;
  </code></pre>