title: Adding image do DataGrid programically in C# wpf project - how?
body: <p>I have a problem.</p>
  
  <p>I want to write ALL things programically in C#, without VS Designer.</p>
  
  <p>So, I'm creating an image and and DataGrid (and I'm adding it as a child of MainWindow Grid):</p>
  
  <pre><code>  Image img = new Image();
    Uri uri = new Uri(@"C:\d1.jpg");
    img.Source = new System.Windows.Media.Imaging.BitmapImage(uri);
  
    DataGrid dg = new DataGrid();
    grid1.Children.Add(dg);
  </code></pre>
  
  <p>Then I want to add 4 columns for example, 3 of text and one of image. So at first I need to create a DataTable and DataRow with sample data:</p>
  
  <pre><code>  DataTable dt = new DataTable();
  
    dt.Columns.Add("Column1");
    dt.Columns.Add("Column2");
    dt.Columns.Add("Column3");
    dt.Columns.Add("Column4", typeof(Image)); // type of image!
  
    DataRow dr = dt.NewRow();
    dr[0] = "aaa";
    dr[1] = "bbb";
    dr[2] = "ccc";
    dr[3] = img; // add a sample image
  
    dt.Rows.Add(dr);
  </code></pre>
  
  <p>Now I have a DataTable with 4 columns and 1 row of data.</p>
  
  <p>Then all I need to do is to set ItemsSource of DataGrid like this:</p>
  
  <pre><code>dg.ItemsSource = dt.DefaultView;
  </code></pre>
  
  <p>What I'm doing wrong? Why on the final grid there is System.Windows.Controls.Image in a row instead of real image? Do I need to bind it or something?</p>
  
  <p>All things I need to do programically, without designer.</p>
  
  <p>How to display real image instead of that string?</p>