美好的一天!
我尝试默认使用空行创建DataGrid,如果用户删除所有行 - datagrid,请添加新的空行。
我尝试这样做:
<DataGrid AutoGenerateColumns="False" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
Name="dg1"
ItemsSource="{Binding Path=RowColl}"
CanUserAddRows="True"
CanUserDeleteRows="True"
IsEnabled="True"
IsReadOnly="False"
> ...</DataGrid>
在* .xaml.cs:
RowColl = new ObservableCollection<Row>();
dg1.ItemsSource = RowColl;
但没有空行......
请告诉我如何在默认情况下获取空行并始终将1行视为空。 谢谢!
答案 0 :(得分:-1)
使用此
myDataGridView.AllowUserToAddRows = true;
它将在datagrid视图的末尾显示空行。