tags:

views:

25

answers:

1

Hi,
I have a wpf datagrid which is bound to an observable collection. Currently I don't have the NewItemPlaceHolder. How can I enable NewItemPlaceholder (an empty row in the bottom to add new rows)? Here is how I declared my datagrid:

    <WpfToolkit:DataGrid x:Name="grid"
        ItemsSource="{Binding Path=SampleObservableCollection}" 
        HorizontalScrollBarVisibility="Hidden" SelectionMode="Single"
        CanUserAddRows="True" CanUserDeleteRows="True"
        CanUserResizeRows="False" CanUserSortColumns="False"
        CellEditEnding="grid_CellEditEnding"
        CurrentCellChanged="grid_CurrentCellChanged" 
        AutoGenerateColumns="False"
        RowHeaderWidth="17" RowHeight="25">
        <WpfToolkit:DataGrid.Columns> ...

Thanks

A: 

Make sure that the type of the objects in the collection has a default constructor. If it does not, then the DataGrid isn't able to create a new one for the new row.

Also see this other StackOverflow answer.

Quartermeister
That was it. I was missing a default constructor. Thanks!!!
VNarasimhaM