In Grid, Auto means the content width will define the column width, and Star means the column width will use the left space available.
However in Table, I find a different behavior. If you have 3 columns with the width: 100, Auto, 100; the width second column does not depend on its content. Instead, it uses the remaining space available as its width.
Moreover in Table, if you combine Star column with Auto or fixed pixel width column, the Star column will be very small, around 1 character width.
Could anyone explain whether this is a bug in Table, or it's simply the default behavior?
Additional info: If I combine Auto with fixed width, the Auto column (the second) will use the remaining space available.
<Table>
<Table.Columns>
<TableColumn Width="100"/>
<TableColumn Width="Auto"/>
<TableColumn Width="100"/>
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>...
<TableCell>...
<TableCell>...
</TableRow>
</TableRowGroup>
</Table>
If I combine Star with fixed width or Auto, the Star column's width is very small, and the other columns will be divided equally on the remaining space available.
<Table>
<Table.Columns>
<TableColumn Width="*"/>
<TableColumn Width="100"/>
<TableColumn Width="100"/>
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>...
<TableCell>...
<TableCell>...
</TableRow>
</TableRowGroup>
</Table>
Auto − It will take space which are required for the controls in that specific row/column. Star (*) − It will take the remaining space when Auto and fixed sized are filled.
In a WPF Grid, Width="*" or Height="*" means proportional sizing.
Auto means that a column is given as much width as the elements within it require. The width of * sized columns is calculated by allocating space for the Auto , and fixed width columns, and then dividing up the remaining space.
Okay I understand that this is not an answer as such, but since there's no one else responding at the moment, I figured I'd try to help out a little bit. This appears to be a bug that's been around since at least WPF 4.0
https://connect.microsoft.com/VisualStudio/feedback/details/724483/the-width-of-tablecolumns-in-a-wpf-flowdocument-doesnt-work-with-non-star-widths
Tables appear to be relatively useless unless you're using the star notation, which, as near as I can tell basically functions more like a percentage, but there's some flaky behavior in there as well.
If you set everything to star it basically does the equivalent of auto across the board, but setting one or more elements to anything but star will cause the existing stars to occupy 1 percent the total width, likewise if you changed it to 50* it would take up 50 percent of the total width.
I know this isn't extremely helpful, but it's the best I could do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With