Reputation: 33
I'm trying to get my DataGrid to scale the Row Height, Column Width with the Window Size so that it can scale to any resolution. This sort of works but since I have the datagrid in a viewbox not all rows are showing and there isn't a horizontal scroll available. See Image.
<Grid x:Name="grid1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="TB1" Grid.Row="0" Text="League Name"/>
<DataGrid Name="DG1" ItemsSource="{Binding}" Grid.Row="1" AutoGenerateColumns="False" GridLinesVisibility="None" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<DataGrid.Columns>
<DataGridTextColumn Header="a" Binding="{Binding a}" />
<DataGridTextColumn Header="b" Binding="{Binding b}" />
<DataGridTextColumn Header="c" Binding="{Binding c}" />
<DataGridTextColumn Header="d" Binding="{Binding d}" />
<DataGridTextColumn Header="e" Binding="{Binding e}" />
<DataGridTextColumn Header="f" Binding="{Binding f}" />
<DataGridTextColumn Header="g" Binding="{Binding g}" />
<DataGridTextColumn Header="h" Binding="{Binding h}" />
</DataGrid.Columns>
</DataGrid>
<Border Grid.Row="2">
<Image Source="Resources/Logo.png" />
</Border>
</Grid>
Upvotes: 0
Views: 1212
Reputation: 1585
Get rid of the Viewbox and set your DataGrid's Vertical and Horizontal alignments to 'Stretch'. You should also set your RowDefinition to "*" or just get rid of it all together (You don't need it since it is your only row).
Upvotes: 1