title: Dynamically draw an Image on a Canvas in Silverlight
body: <p>I am attempting to put together a small game engine, in Silverlight.</p>
  
  <p>However, I am currently stuck on a rather lower level issue: The ability to draw images, in different positions.  I intend on doing this dynamically through code, as, from what I've seen, most everything in XAML tends to be something that is at least somewhat static.</p>
  
  <p>I have changed the base 'grid' into a Canvas, instead, so that I could draw anywhere on it.  Perhaps this was a bad idea, though, I don't know.  Any or all advice would help.</p>
  
  <pre><code>        InitializeComponent();
          Image img = new Image();
          img.Source = new BitmapImage(new Uri("Generic URL here"));
          ((BitmapImage)(img.Source)).DownloadProgress += new System.EventHandler&lt;DownloadProgressEventArgs&gt;(TestEventHandler);
  
          Rect position = new Rect(new Point(25, 25), img.RenderSize);
  
          LayoutRoot.Children.Add(img);
          img.Arrange(position);
  </code></pre>
  
  <p>My original attempt, above, was to use the Arrange function, above, to 'move' the image to a new position.  However, I have no idea how this works, and when I did the above code, the image no longer displayed on screen.</p>
  
  <p>An unrelated question: is it possible to store images with the Silverlight application, as to not have them loaded via URL?  I know it likely is, but what I really mean to ask, is how I would go about that?</p>
  
  <p>Thank you all for any help.</p>
  
  <p>-Stefan Zuefeldt</p>