I've got 2 Columns
that are divided by a GridSplitter
. And I want to set the MaxWidth of the columns in percentage (e.g. 5*
) but it doesn't work. Is there any other way to do it?
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<GridSplitter ResizeDirection="Columns"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Height="auto"
Background="#c1c1c1"
BorderBrush="#c1c1c1"
BorderThickness="1"/>
If you check the MSDN documentation for ColumnDefinition
, MinWidth
and MaxWidth
are of type double
, not like Width
property, which is of type GridLength
- that's why it supports Auto
, *
as valid values for Widtth. So, Specifying MinWidth, MaxWidth interms of percentages is not a straight forward thing.
However, you could write a Converter
, which can take Auto, *
as input values and do the math and then set a valid value for MaxWidth.