//Allocate array
Image frame = new Image();
frame.Stretch = Stretch.None;
colorBitmap = new WriteableBitmap(sensor.ColorStream.FrameWidth, sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
//Write the pixel data into bitmap
do
{
colorBitmap.WritePixels(new Int32Rect(0, 0, colorBitmap.PixelWidth, colorBitmap.PixelHeight), colors, colorBitmap.PixelWidth * sizeof(int), 0);
frame.Source = colorBitmap;
Console.WriteLine(frame.ActualHeight);
} while(frame.RenderSize == new Size(0, 0));