0

I am trying to use expandoObject as a row for the datagrid in WPF.

And I find it works fine until the cell is edited.

Here is the core code:

 ExpandoObject row = new ExpandoObject();           
 ((IDictionary<string, Object>)row).Add(strColumnId, strValue);
 dg.Items[0] = row;

The datagrid can display the row correctly, but if I click the cell to edit it, I get the error

'EditItem' is not allowed for this view" will be displayed.

Mahendra Liya
  • 12,912
  • 14
  • 88
  • 114
NorSD NorSD
  • 225
  • 4
  • 14
  • http://stackoverflow.com/questions/19334326/wpf-datagrid-edititem-expation/19334755#19334755 – Nitin Apr 24 '14 at 06:47

2 Answers2

0

OK, I know what's wrong with it. We should use : dg.ItemSources = new dynamic[]{ expandoObject }

And it works now!

what a stupid boy i am!

NorSD NorSD
  • 225
  • 4
  • 14
0

I seen this error in 3 cases

case1 : this error shown if double clicking the datagrid then(custom datagrid which contains processed data like analysis)

Simply, Set in Datagrid IsReadOnly="True"

case2 : this error shown after editing the datagrid, must set during RowEditEnding

  (sender as DataGrid).CommitEdit(DataGridEditingUnit.Row);

case3 : this error shown after RowEditEnding event, then must see where the datagrid is reloading the data, it can happen if viewsource or datagrid is already in use and we try to override the data manually

Let me know if any new cases you seen