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

时间秒杀一切 提交于 2019-12-03 04:12:52

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"

I've got it

on Datagrid XAML, put the attribute:

IsReadOnly="True"
Sawarkar vikas

CanUserAddRows="False" and IsReadOnly="True" combination of both is better to ensure any additional inconveniences.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!