Hey everyone. I have a problem with a datagrid in my window. I want it to extend only to its needed size if it doesn't fill the entire window or show a scroll bar if it does take up the entire screen. Here's my xaml
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<DataGrid Grid.Row="0" Name="dg">
<DataGrid.Columns>
<DataGridTextColumn Header="Col1"/>
<DataGridTextColumn Header="Col1"/>
</DataGrid.Columns>
</DataGrid>
<GroupBox Grid.Row="2" Margin="5">
<Button>Click</Button>
</GroupBox>
</Grid>
If I set the row height for the datagrid to * it extends the datagrid's gray background down the entire row. But if I set the height to auto, then it won't show a scrollbar when there are too many items for the window.
Any ideas?
Have you tried nesting the DataGrid in a ScrollViewer?
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