xaml - How to display from one model but save to another -
i have listview
user can select multiple items chorelist
. however, i'd items selected save model contains list of chores
below attempt @ that, isn't working. personsingle
object contains 0 assignedchores
<listview x:name="chorelist" borderbrush="white" borderthickness="1" grid.row="1" displaymemberpath="summary" itemssource="{binding chorelist, mode=oneway}" selectedvalue="{binding personsingle.assignedchores, mode=twoway}" selectionmode="multiple"/>
what need add chores select personsingle.assignedchores
list?
update answer:
private void chorelist_selectionchanged(object sender, selectionchangedeventargs e) { if (e.removeditems.count > 0) { foreach(win8chores.model.databasetables.chore item in e.removeditems) { win8chores.model.databasetables.chore mychore = new model.databasetables.chore(); mychore = item; vm.personsingle.assignedchores.remove(mychore); } } if (e.addeditems.count > 0) { foreach (win8chores.model.databasetables.chore item in e.addeditems) { win8chores.model.databasetables.chore mychore = new model.databasetables.chore(); mychore = item; vm.personsingle.assignedchores.add(mychore); } } }
xaml:
<listview x:name="chorelist" borderbrush="white" borderthickness="1" margin="401,322,613,150" grid.row="1" displaymemberpath="summary" itemssource="{binding chorelist, mode=oneway}" selectionmode="multiple" selectionchanged="chorelist_selectionchanged"/>
i'm still wondering if there way strictly using binding. selectionchanged event worked.
with mutil-select listview, don't use selectedvalue property data binding. need access listview.selecteditems property list of selected items. handle selectionchanged event respond changes.
Comments
Post a Comment