ColumnDefinition MinWidth is not working correctly

I use Grid in WPF (xaml) and I have some weird effect when using the MinWidth property in ColumnDefinition. For example, when I use 9 ColumnDefinition, and each ColumnDefinition has the Width = "*" property, and one of the middle columns also has the MinWidth property, then the size of the other columns is incorrect.

Well, it's hard to describe, but this xaml code illustrates this well:

  <Grid Width="500">  
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*" MinWidth="250"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Border Grid.Column="0" Background="Green"/>
    <Border Grid.Column="1" Background="Blue"/>
    <Border Grid.Column="2" Background="Red"/>
    <Border Grid.Column="3" Background="Yellow"/>
    <Border Grid.Column="4" Background="Purple"/>
    <Border Grid.Column="5" Background="Orange"/>
    <Border Grid.Column="6" Background="Azure"/>
    <Border Grid.Column="7" Background="LightBlue"/>
    <Border Grid.Column="9" Background="LightGreen"/>
  </Grid>

When you run this xaml code, you will see that the first 3 columns have different widths than the last 5 columns. Where I expected all to have the same width.

Does anyone know if this is a mistake. And if there is a way to do it right.

Thanks in advance.

+3
2

, - , .

, , , :

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="1.0000001*" MinWidth="250"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

, , ...

+10

, . 500 : , , 250 . WPF : , , 9 250 , 500 ? , , - .

. ? ?

0

Source: https://habr.com/ru/post/1734519/


All Articles