A novice at WPF / XAML, I’ve been wrestling with layout and trying to get it uniform. I’m using a listbox of grids, with different data in different columns. I’ll start by saying the desired behavior: uniform start and end positions for the columns, which I thought could be achieved by using *-based Widths in the ColumnDefinitions.
And in the most recent diff from the GitHub link at the bottom, with the dummy data, the columns are uniform with various string lengths. But for some reason when I use the actual data drawn from the DirectorySizers the uniformity goes out the window, where the second column starts at different positions based on the length of DirPath. The only thing I could think was if the data was somehow longer than the column, which doesn’t seem to be the case (inspecting in memory DirPath comes out appropriately trimmed).
Any solutions / explanations for this? I’m at a loss.
You should look into using Grid.IsSharedSizeScope on your listbox. Using this you can make all the grids share the same column size based on the property “SharedSizeGroup” in the columnDefinition. I know this isn’t a thorough explanation so please just google on Grid.IsSharedSizeScope and you find what you need.
Also the diference in behaviour you see may be explained by the different structure of the data source you are using. Instead of doing an array of string where the exact same value gets bound to each column try setting up a class with two different string values and binding to that. That way it will be a more valid comparision to your DirectorySizer object