我正在用C#创建一个DataTable。我将表设置为一定数量的行和列。但是,最后一行我希望它占用整个表。如何使最后一行占据整个数据表?该表已绑定到xaml文件中的DataGrid。我不确定是否要在C#文件或xaml文件中进行更改。
public DataTable TestTable { get; set; }
private void SetUpTable()
{
this.TestTable = new DataTable();
this.TestTable.Columns.Add("Players");
this.TestTable.Columns.Add("Health");
this.TestTable.Columns.Add("Power");
this.TestTable.Columns.Add("Speed");
this.TestTable.Rows.Add("Player1");
this.TestTable.Rows.Add("Player2");
this.TestTable.Rows.Add("Player3");
this.TestTable.Rows.Add("Winner");
this.PopulateTable();
}
<DataGrid
filtergrid:DataGridExtensions.UseBackgroundWorkerForFiltering="True"
filtergrid:DataGridExtensions.IsFilterVisible="True"
filtergrid:DataGridExtensions.IsClearButtonVisible="False"
AutoGenerateColumns="True"
ItemsSource="{Binding TestTable, Mode=Twoway}"
Grid.Row="3"
Grid.ColumnSpan="2"
MaxHeight="400"
MinHeight="100"
MaxWidth="750"
MinWidth="750"
Margin="5, 10, 0, 0"
HorizontalAlignment="Left"
EnableRowVirtualization="True"
IsReadOnly="True"
CanUserAddRows="False">
</DataGrid>