UIImage ScaledImage(UIImage image, nfloat maxWidth, nfloat maxHeight)
{
var maxResizeFactor = Math.Min(maxWidth / image.Size.Width, maxHeight / image.Size.Height);
var width = maxResizeFactor * image.Size.Width;
var height = maxResizeFactor * image.Size.Height;
return image.Scale(new CoreGraphics.CGSize(width, height));
}