我只是想知道是否可以通过网格本身将行添加到数据网格(即对象模型的 ObservableCollection)?
我并不是特别想使用新的 View 来做到这一点(尽管如果我这样做也不会是世界末日)
谢谢
最佳答案
您可以使用DataGrid.CanUserAddRows
属性:
When this property is set to true a blank row is displayed at the bottom of the
DataGrid
. A user can enter a new item into the blank row. Adding a new row adds an item to the ItemsSource. You can set default values for the new item by handling theInitializingNewItem
event and setting the values programmatically.
示例:
<DataGrid Name="MyDataGrid"
CanUserAddRows="True" ... />
关于c# - WPF 通过网格本身向 DataGrid 添加行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23045736/