c# - Two way binding requires Path or XPath, DataGrid binding -



c# - Two way binding requires Path or XPath, DataGrid binding -

i have datagrid filled in user, xaml:

<datagrid itemssource="{binding path=input.inloopaangepast, mode=twoway, updatesourcetrigger=propertychanged}"> <datagrid.columns> <datagridtextcolumn binding="{binding path=typeoppervlak}"/> <datagridtextcolumn binding="{binding path=typeafstroming}"/> <datagridtextcolumn binding="{binding path=parameters[0].double}"/> <datagridtextcolumn binding="{binding path=parameters[1].double}"/> <datagridtextcolumn binding="{binding path=parameters[2].double}"/> <datagridtextcolumn binding="{binding path=parameters[3].double}"/> <datagridtextcolumn binding="{binding path=parameters[4].double}"/> <datagridtextcolumn binding="{binding path=parameters[5].double}"/> <datagridtextcolumn binding="{binding path=parameters[6].double}"/> </datagrid.columns> </datagrid>

viewmodel:

inloopaangepast = new observablecollection<inloop>();

and:

public class inloop : inotifypropertychanged { public inloop() { parameters = new observablecollection<inloopparameter>(); } private string _typeoppervlak; private string _typeafstroming; private string _omschrijving; public observablecollection<inloopparameter> _parameters; public string typeoppervlak { { homecoming _typeoppervlak; } set { _typeoppervlak = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("typeoppervlak")); } } } public string typeafstroming { { homecoming _typeafstroming; } set { _typeafstroming = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("typeafstroming")); } } } public string omschrijving { { homecoming _omschrijving; } set { _omschrijving = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("omschrijving")); } } } public observablecollection<inloopparameter> parameters { { homecoming _parameters; } set { _parameters = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("parameters")); } } } public event propertychangedeventhandler propertychanged; } public class inloopparameter : inotifypropertychanged { public inloopparameter() { } private string _naam; private string _string; private double? _double; public string naam { { homecoming _naam; } set { _naam = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("naam")); } } } public string string { { homecoming _string; } set { _string = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("string")); } } } public double? double { { homecoming _double; } set { _double = value; if (propertychanged != null) { this.propertychanged(this, new propertychangedeventargs("double")); } } } public event propertychangedeventhandler propertychanged; }

i can come in first 2 fields (typeoppervlak , typeafstroming) fine, when come in 1 of other fields error "two way binding requires path or xpath". doing wrong?

you need initialize list _parameters user can edit them. initialize in constructor:

public inloop() { _parameters = new observablecollection<inloopparameter>(); _parameters.add(new inloopparameter()); _parameters.add(new inloopparameter()); _parameters.add(new inloopparameter()); _parameters.add(new inloopparameter()); _parameters.add(new inloopparameter()); _parameters.add(new inloopparameter()); _parameters.add(new inloopparameter()); }

you need add together items in list equal index binding on ui (7 items precise).

c# wpf data-binding datagrid

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -