I have a Grid which has two columns, first column has a DataGrid and second column has another grid. I expect DataGrid to expand to take full space when Visibility of second grid is set to 'collapsed'. Following is the code snippet:
<Grid Grid.Row="1" HorizontalAlignment="Left" Width="344">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="24"/>
</Grid.ColumnDefinitions>
<DataGrid MaxWidth="344" Grid.Column="0" SelectedItem="{Binding Dummy, Mode=TwoWay}" Background="DarkGray"
ItemsSource="{Binding DummyList}" SelectionMode="Single" AutoGenerateColumns="False" RowHeaderWidth="0" GridLinesVisibility="All">
<DataGrid.Columns>
<DataGridTemplateColumn Header="" Width="35">
<DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="" Width="*" MinWidth="85">
<DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="" Width="*" MinWidth="90" >
<DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="" Width="*" MinWidth="80">
<DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="" Width="*" MaxWidth="25" Visibility="Collapsed">
<DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Grid Grid.Column="1" Margin="0,1,0,0" Background="DarkGray" Visibility="Collpased">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
</Grid>
</Grid>
Even when I set visibility of Grid in second column to collapsed, DataGrid do not takes up the whole space, second column remains empty. Do I have wrong expectation, If yes/no, how can I achieve this behavior?