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>
To make a column read-only programmaticallySet the DataGridViewColumn. ReadOnly property to true .
A DataGrid is a control that displays data in a customizable grid. It provides a flexible way to display a collection of data in rows and columns. The hierarchical inheritance of DataGrid class is as follows −
It is just a guess based on this question.
Set ScrollViewer.HorizontalScrollBarVisibility="Disabled"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With