I am creating WPF application with ModernUI interface. Its a kind of photo gallery. Images are stored in some folder and are retrieved according to appropriate record in database. So my ViewModel gets information from database and binds "URI" column to Source property of Image.
What I need to do is to position these images to a view like in grid. Width and height of images is constant. Challenge here is that before runtime I do not know how many elements I have, so Grid should be created dynamically. I would be better if number of columns will be automatically counted depending on width of grid. For example, image width is 200, right margin is 50, so if grid (or parent element, never mind) width is 800, so we have 3 columns. But I can set number of columns explicitly; The most important thing is to position images so that it will look like a grid.
ViewModel returns ObservableCollection of elements (could be change to any necessary structure). I really appreciate XAML code with templates defined.