Add image from code
<p>OK this should be an easy one.
I've seen several other questions about that and it should work but inexplicably it doesn't. 
So I have that Image</p>

<pre><code> &lt;Image Name="LogoImage" Width="50" Height="50"&gt; 
</code></pre>

<p>and I want to set it through code.
So I have a s/r  StrPath2ResizedBmpSize which resizes and gets a BitmapImage. That works because if in debug I take a look at the bmp it's ok.</p>

<p>Then I want to get the Image to set the LogoImage through this routine:</p>

<pre><code>LogoImage = ImageUtilities.StrPath2ResizedImgSize(strFilename, 50, 50);
</code></pre>

<p>with</p>

<pre><code>public static Image StrPath2ResizedImgSize(string strPath, int newWidth, int newHeight)
{
  var bmp = new BitmapImage();
  bmp = BitmapUtilities.StrPath2ResizedBmpSize(strPath, newWidth, newHeight);
  Image img = new Image();
  img.Source = bmp;&lt;-----image is not set and it's null
  return img;
}
</code></pre>

<p>but it doesn't work and the image is an image with null parameters.
Where is the problem?
Thank you</p>