我有一个带DataGrid的WPF项目。它有500个动态添加的列。它适用于整数或字符串等数据类型。但是,如果我使用复选框制作500个布尔列 - DataGrid需要几秒钟才能滚动。是否有可能以某种方式优化布尔列/复选框?
我的DataGrid定义如下:
<ext:ExtDataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="3"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
EnableRowVirtualization="True" EnableColumnVirtualization="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
ItemsSource="{Binding Path=DataTableSample1, Mode=TwoWay}"
SelectedItem="{Binding DataTableSample1SelectedItem, Mode=TwoWay}">
</ext:ExtDataGrid>
ItemsSource是一个DataTable对象,列添加如下:
for (int i = 0; i < 500; i++)
{
DataColumn dataColumnBoolean = new DataColumn(i.ToString());
dataColumnBoolean.DataType = Type.GetType("System.Boolean");
dataTable.Columns.Add(dataColumnBoolean);
}