tags:

views:

772

answers:

2

Hi,

I have a program where I need the user to input data in a datagrid. I though the simple act of setting the 'CanUserAddRows' would be enough to let the user add new rows, but it seem that it won't cut it.

Is there something else I need to define to make them work? My datagrid have combo boxes and textboxes in them so it's pretty common controls.

The code I have so far is this

<dg:Datagrid Name="GridFournisseur" ItemsSource="{Binding}" 
     Margin="423,41,23.5,0" Height="193" VerticalAlignment="Top" 
     CanUserAddRows="True" CanUserDeleteRows="True" IsTabStop="True" RowHeight="12"                         SelectionUnit="CellOrRowHeader">

    <dg:DataGrid.Columns>

        <dg:DataGridComboBoxColumn Header="Fournisseur" Width="*" MinWidth="150"                                                
                                       IsReadOnly="False" />

        <dg:DataGridTextColumn Header="Prix" Width="SizeToHeader" MinWidth="50"
                                       Binding="{Binding Categorie}" 
                                       IsReadOnly="False"/>
        <dg:DataGridTextColumn Header="Délai" Width="SizeToHeader" MinWidth="50"
                                       Binding="{Binding NoPiece}" 
                                       IsReadOnly="False"/>
    </dg:DataGrid.Columns>
</dg:DataGrid>

I just have this dataGrid in which I would like to edit its content and at the beginning it's empty.

A: 

CanUserAddRows is the correct property. Perhaps share some sample code.

Taylor Leese
A: 

It could be any of a number of things. Please take a look at this article.

The problem is most likely that you are binding to a collection view that does not support adding items. I believe that the grid might be expecting a collection view that implements IEditableCollectionView or IBindingList, interfaces that support adding items.

siz