title: Mapping property values to conditions
body: <p>I am new to WPF and C#. I have a button in my GUI that is presented as an image. However, the image displayed depends on certain conditions. Depending on the conditions, the button could be one of 5 images. I have coded it like this :</p>
  
  <p>View:</p>
  
  <pre><code>&lt;Button x:Name="bShow" HorizontalAlignment="Left" Margin="200,0,0,0" VerticalAlignment="Top" Width="200" Height="200" &gt;
          &lt;Image Source="{Binding myShowProp}"/&gt;
  </code></pre>
  
  <p>Property myShowProp is defined in MainWindow.xaml.cs :</p>
  
  <pre><code>public string myShowProp // This property decides what image appears inside the button
  {
      get { return privProp; }
      set 
      { 
          privProp = value;
          OnPropertyChanged("myShowProp");
      }
  }
  </code></pre>
  
  <p>A routine called <code>SetButtonImage</code> is responsible for the logic that maps certain conditions to certain images. It is coded inside MainWindow.xaml.cs as :</p>
  
  <pre><code>private void SetButtonImage() 
  {
       if ( /* condition1 */)
           myShowProp = image1;
       else if ( /* condition2 */)
           myShowProp = image2;
       else if ( /* condition3 */)
           myShowProp = image3;
       else if ( /* condition4 */)
           myShowProp = image4;
       else
           myShowProp = image5;
  
  }
  </code></pre>
  
  <p>Can you show me a better way of doing the above, I don't imagine a ubiquitous use of <code>if</code> being the best design, seems like I am missing something.</p>
  
  <p>Another motivation behind this is that I have a designer, and if this is something you could do in BLend, at control properties level, then I would rather have him do it in blend, instead of adding to the code-behind.</p>
  
  <p>P.S. One of the things I am going to do is to refactor my existing code as per the MVVM paradigm.</p>