Is it possible to stretch columns or the last column to fill all the available space of the data grid?
<DataGrid Grid.Row="0" AutoGenerateColumns="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="dataGrid1" ItemsSource="{Binding Customers}" />
My columns are Auto generated.
Yes, I think you are looking for the AutoSizeMode property.
int n = grid.Columns.Count;
grid.Columns[n].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Edit: Try setting the width to "*" as seen below. You'll have to do this in the code if your columns are auto-generated.
<DataGrid>
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" />
<DataGridTextColumn Width="*" />
</DataGrid.Columns>
</DataGrid>
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