I am dynamically adding images using view boxes to a UniformGrid
.
for (int i = 0; i < count; i++)
{
var viewbox = new Viewbox();
var filePath = "myFilePath";
if (!File.Exists(filePath)) continue;
var newImage = new Image();
var bitmapImage = new BitmapImage(new Uri(filePath));
newImage.Source = bitmapImage;
viewbox.Child = newImage;
viewbox.SetValue(Grid.RowProperty, i);
ImageGrid.Children.Add(viewbox);
}
The problem I'm running into is where the images are different sizes, horizontally or vertically.
A good way to visualize whats happening. If there's 2 images on screen, with the first image being wider and shorter than the second image. When I shrink the window horizontally, the first image will shrink independently its the same width as the second. Now, when I shrink the window vertically, the second image will shrink independently until its the same height as the first.
How do I make the 2 images scale together without setting the view box stretch property to fill?