Reputation: 341
I have a Grid in WPF where the last column's size is Auto. However, in that column is text that, when I mouse over it, turns from normal to Bold, making the text a little bit bigger (as bold text generally is). The net effect is that the column gets bigger, moving all of the other content around, then smaller when I mouse away, moving everything else again.
What I'd like to do is define my column width to have a little bit of extra but still be Auto width, so that when this resize occurs due to mouse-over it doesn't create such a jarring effect.
I don't have any idea how wide it will be ahead of time; it can very quite a lot. Obviously if you change the entry the column grows, but I just want to keep the bolding effect from causing a rapid grow/shrink every time my mouse gets too close.
Upvotes: 0
Views: 1734
Reputation: 10865
You cannot define a Grid Column to Auto with some room to grow unless it is going to take the entire space using the "*" value.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="40*" />
</Grid.ColumnDefinitions>
Try experimenting and see what fits your layout width. Having two '*' with only two column definition will make the column's width to 50% first column, 50% second column.
Upvotes: 1