Honestly I didn't believe you when I read this, so I had to go off and test it myself, and indeed you are correct. I don't think that you'll have any luck finding rules though because further investigation led me to believe it is a bug in the WPF grid. I performed a number of tests to see if I could figue out the behaviour, but if you just want to know the final conclusions feel free to scroll past the following diatribe.
Sorry if the results aren't clear, they are how I wrote them as a worked. The first three numbers are the sizing values I put in for each column and rest is the resultant sizes.
Test 1:
<Grid Height="300" Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="..."/>
<ColumnDefinition Width="..."/>
<ColumnDefinition Width="..."/>
</Grid.ColumnDefinitions>
<Button Grid.ColumnSpan="2" Content="QWERTYUIOP"/>
</Grid>
Grid 300 X 300 hosting a contol 80 pixels wide. The grid has three columns and the control spans columns 0 and 1:
30 , auto, * - column 0 - 80, column 1 - 0, column 2 - 220
auto, auto, * - column 0 - 40, column 1 - 40, column 2 - 220
auto, 30 , * - column 0 - 0, column 1 - 80, column 2 - 220
* , 30 , * - column 0 - 135, column 1 - 30, column 2 - 135
* , 30 , 26* - column 0 - 10, column 1 - 30, column 2 - 260
* , auto, * - column 0 - 150, column 1 - 0, column 2 - 150
* , auto, 30* - column 0 - 10, column 1 - 0, column 2 - 290
30 , 30 , * - column 0 - 30, column 1 - 30, column 2 - 240
* , * , 28* - column 0 - 10, column 1 - 10, column 2 - 280
So from this I can come up with a number of rules:
- If an element spans an auto sized cell and a non-auto sized cell the auto sized cell will be sized to 0
- If an element spans a fixed cell and an auto cell then the fixed cell's width will increase to the minimum that can contain the whole object
- If an element spans a * sized cell and an auto sized cell then the * sized cell will have its expected size
- If an element spans two auto sized cells they will expand so as to fit the object and be equal in width
- If an element spans cells that don't include an auto cell then the cells will have their expected size
Test 2:
<Grid ShowGridLines="True" Height="300" Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="..."/>
<ColumnDefinition Width="..."/>
<ColumnDefinition Width="..."/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.ColumnSpan="2" Content="QWERTYUIOP"/>
<Button Grid.Row="1" Grid.Column="1" Content="QWERTYUIOP"/>
</Grid>
Grid 300 X 300 with 3 columns hosting one control 80 pixels wide spaning columns 0 and 2 on row 0 and a second control 80 pixels wide only in column 1 of row 1
30 , auto, * - column 0 - 30, column 1 - 80, column 2 - 190
auto, auto, * - column 0 - 0, column 1 - 80, column 2 - 220
auto, 30 , * - column 0 - 0, column 1 - 80, column 2 - 220 (*)
* , 30 , * - column 0 - 135, column 1 - 30, column 2 - 135
* , 30 , 26* - column 0 - 10, column 1 - 30, column 2 - 260
* , auto, * - column 0 - 110, column 1 - 80, column 2 - 110
* , auto, 30* - column 0 - 7, column 1 - 80, column 2 - 213
30 , 30 , * - column 0 - 30, column 1 - 30, column 2 - 240
* , * , 28* - column 0 - 10, column 1 - 10, column 2 - 280
(*) This isn't exactly what happens. Column 1 is set to size 80 but only draws part of the non-spanning element. I was using buttons as my elements and the non-spanned button's chrome filled up the 80 pixel wide first column, but the text was trimmed to a size of 30 pixels. Basically it was completely screwed.
From this test I can add two more rules:
- If an auto column is used in a span and can get its size from somewhere it will behave as expected
- If an auto column is used in a span and can not get it's size from somewhere else then the mesuring system will break and may cause graphical corruption.
So, I guess we can combine these rules into one overarcing philosophy:
If an elements spans multiple columns and at least one, but not all, of those columns are auto sizing there must be another that doesn't span to provide a size for the auto sized columns. Otherwise the behaviour is at best unexpected, and at worst corrupting.
Feel free to raise a bug with Microsoft, but since this is now the defined behaviour of the grid control I imagine we're stuck with it for the lifetime of WPF.