title: Silverlight: How to draw images dynamically?
body: <p>s.jpg added to solution with BuildAction==Resource.</p>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;UserControl x:Class=...&gt;
      &lt;Canvas x:Name="LayoutRoot"&gt;            
      &lt;/Canvas&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p><strong>CS</strong></p>
  
  <pre><code>Image Model = new Image(); 
  Model.Source = new BitmapImage(new Uri("/s.jpg", UriKind.Relative)); 
  LayoutRoot.SetLeft(Model, Coor.X); 
  LayoutRoot.SetTop(Model, Coor.Y); 
  Model.Width = 50; 
  Model.Height = 30; 
  LayoutRoot.Children.Add(Model);
  </code></pre>
  
  <p>Here's my question: were is my image? It has't appeared on the screen, though if i change XAML to</p>
  
  <pre><code>&lt;UserControl x:Class=...&gt;
      &lt;Canvas x:Name="LayoutRoot"&gt;
          &lt;Image Source="s.jpg"&gt;&lt;/Image&gt;
      &lt;/Canvas&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>you can see it, also if change CS to</p>
  
  <pre><code>Ellipse Model = new Ellipse(); 
  Model.Fill = new SolidColorBrush(Colors.Gray);
  Model.Stroke = new SolidColorBrush(Colors.Blue); 
  LayoutRoot.SetLeft(Model, Coor.X); 
  LayoutRoot.SetTop(Model, Coor.Y); 
  Model.Width = 50; 
  Model.Height = 30; 
  LayoutRoot.Children.Add(Model);
  </code></pre>
  
  <p>i'll see that ellipse. so what the problem? </p>