c# - WPF DataGrid Editing Difficulty (InvalidOperationException) -
i have datagrid
filling information observablecollection<observablecollection<t>>
t object of mine implements ieditableobject
.
i have datagrid
correctly filling information need. problem when go edit box in exception.
system.invalidoperationexception: 'edititem' not allowed view
followed subsequent stack trace.
i understand binding idea in observablecollection<t>
if want able edit datagrid
items need implement ieditableobject
interface in object t
.
i'm not sure why won't let me edit, although i'm leaning more towards idea need attach object type of view.
i've not found on i'm trying have been successful until point in getting on hurdles. if has insight should appreciated.
also, post code if see believe it's less i've written , more still need write.
edit: added code
private void dg_datacontextchanged(object sender, dependencypropertychangedeventargs e) { datagrid grid = sender datagrid; grid.columns.clear(); tablenode node = e.newvalue tablenode; if (node != null) { infotable dti = new infotable(m_model.editnode.database.path, node.fullname); int index = 0; foreach (string colname in dti.columns) { datagridtextcolumn col = new datagridtextcolumn(); col.header = colname; col.binding = new binding("[" + index + "].info"); //note: .info information string in class t containing data may or may not edited grid.columns.add(col); index++; } grid.itemssource = dti; } }
here binding columns each observablecollection
in observablecollection<observablecollections<t>>
in infotable
. have implemented ienumerable
, inotfiypropertychange
in infotable
.
i'm pretty sure infotable
class needs implement ilist
, too, in order support datagrid editing.
ilist
adds capability of adding , removing items, , datagrid needs manage rows.
Comments
Post a Comment