wpf 多选框 使用滚动条造成选中和取消选中
操作顺序:
1、手动选中 多选框,每列3个
2、滚动鼠标滚轮或下拉滚动条
3、返回查看之前选中的多选框。
问题的现象:
1、对于DataGridTemplateColumn 选中效果被丢失,剩余最后选中的行保持选中状态
2、对于DataGridCheckBoxColumn选中效果未丢失,滚动时有拖影效果
补充:
1、不使用DataGridCheckBoxColumn的原因是 DataGridCheckBoxColumn列需要单击2次才能选中
2、DataGridTemplateColumn 选中的行被隐藏会触发unchecked事件,造成选中的数据不被记录
3、如果考虑使用ScrollViewer如何保证列头不被看不到
对于DataGrid中以上2中checkbox的使用,不知是否有更优方案,希望得到各位高手的指点。
xaml代码:
public Window1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("1", typeof(Boolean)); dt.Columns.Add("2", typeof(Boolean)); for (int i = 0; i < 200; i++) { DataRow dr= dt.NewRow(); dr[0] = false; dr[1] = false; dt.Rows.Add(dr); } dg.ItemsSource = dt.DefaultView; }