title: DataTriger Style Setter for Image Element
body: <p>I have an image element that is populated via databinding - if the binding returns a path, the image is drawn. If not (path comes in an an empty string), we get no image.</p>
  
  <pre><code>&lt;Image Source="{Binding Path=.Screenshot, Mode=OneWay}" Stretch="Fill"  Margin="5,5,5,5" /&gt;
  </code></pre>
  
  <p>That works well, except that the margin is applied to the layout no matter what (which looks bad for empty images). I figured I'd do a DataTrigger instead that only applies the margin is the path is not empty, but:</p>
  
  <ul>
  <li>Image doesn't seem to have a Style <em>(actually it does, ignore this part)</em></li>
  <li>I don't know how to test for "string is not empty".</li>
  </ul>
  
  <p>What I'd like to do is something like the pseudo-XAML below. Is that possible in XAML? </p>
  
  <pre><code>&lt;Image Source="{Binding Path=.Screenshot, Mode=OneWay}" Stretch="Fill" &gt;
  &lt;Image.Style&gt;
      &lt;Style TargetType="Image"&gt;
          &lt;Setter Property="Margin" Value="0,0,0,0" /&gt;
          &lt;Style.Triggers&gt;
              &lt;DataTrigger Binding="{Binding Path=.Screenshot}" Value="!NullOrEmpty"&gt;
                  &lt;Setter Property="Margin" Value="5,5,5,5" /&gt;
              &lt;/DataTrigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  &lt;/Image.Style&gt;
  </code></pre>
  
  <p></p>
  
  <p>Should I be maybe using an entirely different approach for this?</p>