How to remove DataGrid's blank row when binding to a ObservableCollection?

前端 未结 3 1558
眼角桃花
眼角桃花 2021-02-06 21:19

I\'m getting nuts here with this:

ObservableCollection list = new ObservableCollection();
dgEmployees.ItemsSource = list;
         


        
3条回答
  •  广开言路
    2021-02-06 22:00

    The same problem persist in WPF 4.0 version of DataGrid, and it is caused by the add-new row which it shows automatically for ObservableCollection ItemsSource. Setting IsReadOnly as True it's too radical IMHO.
    I solved it by disabling CanUserAddRows property if you don't need that behavior, but you still want cells to be modified:

    CanUserAddRows="False"

提交回复
热议问题