title: Resize image for use as an image brush
body: <p>I want to </p>
  
  <ul>
  <li>load an image from a resource</li>
  <li>Set the image width, ensuring that it scales it's height proportionally.</li>
  <li>Use it as a background brush</li>
  </ul>
  
  <p>It can't figure out the "setting its width" part.</p>
  
  <p>The compromise I'm currently using is to scale it to half size. This isn't what I ideally want to do, I want to set the width to an absolute value, regardless of what the original image size was.</p>
  
  <pre><code>&lt;BitmapImage x:Key="floorPlan"
          UriSource="/NavigationPathEditor;component/Images/CairnsFloorPlansCropped.png"/&gt;
  
  &lt;TransformedBitmap x:Key="resizedFloorPlan" Source="{StaticResource floorPlan}"&gt;
      &lt;TransformedBitmap.Transform&gt;
          &lt;ScaleTransform 
                  CenterX="0"   CenterY="0" 
                  ScaleX="0.5"  ScaleY="0.5" /&gt;
      &lt;/TransformedBitmap.Transform&gt;
  &lt;/TransformedBitmap&gt;
  
  &lt;ImageBrush 
        x:Key="floorPlanBrush" 
        TileMode="None" Stretch="None" 
        AlignmentX="Left" AlignmentY="Top"
        ImageSource="{StaticResource resizedFloorPlan}" /&gt;
  </code></pre>
  
  <p>(Incidentally, the above code works at runtime, but throws an error in the designer)</p>