If I set widths of DataGrid (located in RowDetailesTemplate) columns using "*" - columns scaling doesn't work
<DataGrid>
...
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid Margin="10" Height="100">
<DataGrid.Columns>
<DataGridTextColumn Header="header A" Width="3*" />
<DataGridTextColumn Header="header B" Width="2*" />
<DataGridTextColumn Header="header C" Width="*" />
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
but if I replace DataGrid by Grid and set it's columns width using "*" scailing works
<Grid Margin="5" Height="100">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="header A" Background="LightGray" TextAlignment="Center" HorizontalAlignment="Stretch"></TextBlock>
<TextBlock Text="header B" Grid.Column="1" TextAlignment="Center" HorizontalAlignment="Stretch"></TextBlock>
<TextBlock Text="header C" Grid.Column="2" Background="LightGray" TextAlignment="Center" HorizontalAlignment="Stretch"></TextBlock>
</Grid>
how to fix DataGrid scaling ?
solution:
<DataGrid HorizontalScrollBarVisibility="Disabled">
...
<DataGrid.RowDetailsTemplate>
...
</DataGrid.RowDetailsTemplate>
</DataGrid>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…