title: Silverlight images not displaying
body: <p>I am creating application in Silverlight. There is only a DataGrid right now. I am using WCF RIA Service for getting datas from database. Everything works fine expect Images. I am getting images as byte array and trying to convert them to BitmapImage using Converter. I want to show images in RowDetailsTemplate of DataGrid.</p>
  
  <p>Here it is:</p>
  
  <pre><code>    &lt;sdk:DataGrid.RowDetailsTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackPanel&gt; 
                  &lt;StackPanel&gt;
                      &lt;Image x:Name="thumbNail"  Width="60" Height="60" VerticalAlignment="Center" ImageFailed="thumbNail_ImageFailed"
                             Source="{Binding gameImage,Converter={StaticResource byteToImageConverter}}"&gt;
                      &lt;/Image&gt;
                  &lt;/StackPanel&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/sdk:DataGrid.RowDetailsTemplate&gt;
  </code></pre>
  
  <p>And converter:</p>
  
  <pre><code>public class ByteToImageConverter : IValueConverter
      {
          public BitmapImage ConvertByteArrayToBitMapImage(byte[] imageByteArray)
          {
              BitmapImage img = new BitmapImage();
              using (MemoryStream memStream = new MemoryStream(imageByteArray))
              {
                  img.SetSource(memStream);
              }
              return img;
          }
  
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              BitmapImage img = new BitmapImage();
              if (value != null)
              {
                  img = this.ConvertByteArrayToBitMapImage(value as byte[]);
              }
              return img;
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
          {
              return null;
          }
      }
  </code></pre>
  
  <p>But images are not displaying. </p>
  
  <p>The method in my wcf service is like that:</p>
  
  <pre><code>   public List&lt;Games&gt; GamesList()
          {
              string gmConn = ConfigurationManager.ConnectionStrings["GamesConnectionString"].ConnectionString;
              var gamesList = new List&lt;Games&gt;();
  
              using (SqlConnection conn = new SqlConnection(gmConn))
              {
                  string sql = @"Select Name, Developer,Longevity,Distributor,Year,State,Type,graphics, gameplay,sound,general,photo From Games join scores on Games.G_ID=Scores.G_ID";
                  conn.Open();
  
                  using (SqlCommand cmd = new SqlCommand(sql, conn))
                  {
                      SqlDataReader dr = cmd.ExecuteReader();
                      if (dr != null)
                          while (dr.Read())
                          {
                              Games game = new Games
                              {
                                  Name = dr.GetString(0),
                                  developer = dr.GetString(1),
                                  Longevity = dr.GetInt32(2),
                                  Distributor = dr.GetString(3),
                                  Year = dr.GetString(4),
                                  State = dr.GetString(5),
                                  Type = dr.GetString(6),
                                  Graphics = dr.GetDouble(7),
                                  Gameplay = dr.GetDouble(8),
                                  Sound = dr.GetDouble(9),
                                  General = dr.GetDouble(10)
                              };
                              if (!dr.IsDBNull(11))
                              {
                                  byte[] blob = new byte[(dr.GetBytes(11, 0, null, 0, int.MaxValue))];
                                  dr.GetBytes(11, 0, blob, 0, blob.Length);
                                  using (MemoryStream ms = new MemoryStream())
                                  {
                                      ms.Write(blob, 0, blob.Length - 0);
                                      Bitmap bm = (Bitmap)Image.FromStream(ms);
                                      using (MemoryStream msJpg = new MemoryStream())
                                      {
                                          bm.Save(msJpg, ImageFormat.Jpeg);
                                          game.gameImage = msJpg.GetBuffer();
                                      }
                                  }
                              }
                              gamesList.Add(game);
                          }
                      return gamesList;
                  }
              }
          }
  </code></pre>
  
  <p>And in mainPage.xaml.cs I am setting ItemsSource of my datagrid.</p>
  
  <pre><code>public partial class MainPage : UserControl
  {
      public MainPage()
      {
          InitializeComponent();
  
          SampleServiceClient client = new SampleServiceClient();
  
          client.GamesListCompleted += new EventHandler&lt;GamesListCompletedEventArgs&gt;(client_GamesListCompleted);
          client.GamesListAsync();
      }
  
      void client_GamesListCompleted(object sender, GamesListCompletedEventArgs e)
      {
          CustomerGrid.ItemsSource = e.Result;
      }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>