WPF DataGrid: Blank Row Missing

后端 未结 7 653
春和景丽
春和景丽 2020-11-30 13:49

I am creating a WPF window with a DataGrid, and I want to show the blank \"new item\" row at the bottom of the grid that allows me to add a new item to the grid

7条回答
  •  情歌与酒
    2020-11-30 14:37

    Finally got back to this one. I am not going to change the accepted answer (green checkmark), but here is the cause of the problem:

    My View Model wraps domain classes to provide infrastructure needed by WPF. I wrote a CodeProject article on the wrap method I use, which includes a collection class that has two type parameters:

    VmCollection
    

    where DM is a wrapped domain class, and DM is the WPF class that wraps it.

    It truns out that, for some weird reason, having the second type parameter in the collection class causes the WPF DataGrid to become uneditable. The fix is to eliminate the second type parameter.

    Can't say why this works, only that it does. Hope it helps somebody else down the road.

提交回复
热议问题