I have a WPF application that I've implemented using the MVVM pattern with a single windows which has a grid that can change dimensions at runtime. The content of the grid cells are always of the same type, however the number of columns in the grid vary depending on the state of the window. I'm new the MVVM pattern and WPF applications in general, so I'm having a hard time understanding how to represent the displayed data in a View Model, and to change the layout of the View accordingly.
The closest answer I've found is in this post which describes using DataTemplates to dynamically change the View based on the ViewModel bound to it, however it doesn't make sense to implement two separate ViewModels with the only difference being that one maintains a single data object, and the other maintains an array or list of the same data object.
WPF MVVM Why use ContentControl + DataTemplate Views rather than straight XAML Window Views?
I also know that I can programmatically configure the grid as in this post, but doing so in conjunction with a View model seems overly complicated, and like it breaks the MVVM pattern.
Programmatically setting the width of a grid column with * in WPF
Is there an approach to handling this problem that doesn't duplicate code or break the MVVM pattern?