title: InteropBitmap to BitmapImage
body: <p>I'm trying to Convert a <code>Bitmap (SystemIcons.Question)</code> to a <code>BitmapImage</code> so I can use it in a WPF Image control.</p>
  
  <p>I have the following method to convert it to a <code>BitmapSource</code>, but it returns an <code>InteropBitmapImage</code>, now the problem is how to convert it to a <code>BitmapImage</code>.  A direct cast does not seem to work.</p>
  
  <p>Does anybody know how to do it?</p>
  
  <p>CODE:</p>
  
  <pre><code> public BitmapSource ConvertToBitmapSource()
          {
              int width = SystemIcons.Question.Width;
              int height = SystemIcons.Question.Height;
              object a = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(SystemIcons.Question.ToBitmap().GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(width, height));
  
              return (BitmapSource)a;
          }
  </code></pre>
  
  <p>property to return BitmapImage: (Bound to my Image Control)</p>
  
  <pre><code>public BitmapImage QuestionIcon
          {
              get
              {
                  return  (BitmapImage)ConvertToBitmapSource();
              }
          }
  </code></pre>