void LayoutCameraImage() { if (sizeAvailable.Width == 0) { return; } double widthAvailable = sizeAvailable.Width - ImageGrid.Margin.Left - ImageGrid.Margin.Right; double heightAvailable = sizeAvailable.Height - ImageGrid.Margin.Top - ImageGrid.Margin.Bottom - TitleGrid.DesiredSize.Height - ButtonGrid.DesiredSize.Height; if (device.CameraInfo.Rotation == 90 || device.CameraInfo.Rotation == 270) { if (heightAvailable < CameraImage.Width) { double height = heightAvailable * (480.0 / 640.0); CameraImage.Width = ImageOverlay.Width = heightAvailable; CameraImage.Height = ImageOverlay.Height = height; } else { CameraImage.Width = ImageOverlay.Width = 640; CameraImage.Height = ImageOverlay.Height = 480; } } else { if (widthAvailable < CameraImage.Width) { double height = widthAvailable * (480.0 / 640.0); CameraImage.Width = ImageOverlay.Width = widthAvailable; CameraImage.Height = ImageOverlay.Height = height; } else { CameraImage.Width = ImageOverlay.Width = 640; CameraImage.Height = ImageOverlay.Height = 480; } } if (widthAvailable < 320) { PageTitle.FontSize = 20; } else { PageTitle.ClearValue(TextBlock.FontSizeProperty); } }