I have a standard WPF grid with 2 columns defined as:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="200" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
...
</Grid>
What I want to achieve is that the second column is automatically sized based on its content and the first column gets all remaining space. However I also want the first column to never have less than 200 pixels. The problem is that with this configuration my auto column will be cut off instead of being resized.
What I really want is WPF to first assign 200 pixels to the first columns, then take all remaining space and ask the content of the second column to size itself with a maximum size restriction of the remaining width. If the content needs less space, it should assign the remaining space to the first column (making it bigger than the 200 pixel).
Use case: My second column is an image with a fixed aspect ratio, so that for a given height there is an optimal width. I also have a first column with some controls that should always be visible. If there is more space available than needed I would like to assign the space to the first column instead of the second.
Is there a way to achieve this with default WPF controls or do I need to write my own Grid for this?
The only time I saw column two being cut off was when width of column 2 + 200 was greater than the width of the grid. I played around and maybe this is a solution for you:
I tried writing
<ColumnDefinition Width="Auto" MaxWidth="400"/>but maxwidth had no effect then.MaxWidth for the Viewbox is calculated as total width – the reserved 200 if that is not obvious.