0

Good day!

I try to make DataGrid with empty row by default and if user delete all rows- datagrid shoud add e new empty row.

I try to do this:

<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>

At *.xaml.cs:

RowColl = new ObservableCollection<Row>();
dg1.ItemsSource = RowColl;

But no empty row ..

Please, tell me how to get empty row by default and get always 1 row as empty. Thank you!

user2545071
  • 1,408
  • 2
  • 24
  • 46
  • Please look at [similar question](http://stackoverflow.com/questions/22330173/editable-datagrid-canuseraddrows-true-not-working), I think it has exactly what you need. – icebat Feb 20 '15 at 14:18

1 Answers1

-1

Use this

myDataGridView.AllowUserToAddRows = true;

It will display empty row at the end of datagrid view.

Yogesh Patel
  • 672
  • 4
  • 9