如何在DataGrid中显示一定数量的行?例如,只有前15个?
DataTable具有动态数据。我需要显示前15行。其余的也应该存在,但不显示。
<DataGrid x:Name="CsvGrid" ColumnWidth="*" ItemsSource="{Binding csvTable}">
DataTable csvTable = new DataTable();
...
CsvGrid.ItemsSource = csvTable.DefaultView;
答案 0 :(得分:0)
<DataGrid x:Name="CsvGrid" ColumnWidth="*" LoadingRow="CsvGrid_LoadingRow" ItemsSource="{Binding csvTable}" />
private void CsvGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = (e.Row.GetIndex()+1).ToString();
if(e.Row.GetIndex() > _showRows - 1) e.Row.Visibility = Visibility.Hidden;
}