wpf - MVVM, two synchronized Grid Data -
i want control adding , removing items 2 list (selected , unselected), this:
but can't find way this; how can use griddata (or similar control gridcontrol of devexpress) binding 2 list , modify it?
problems:
- i can't use observablecollection control
- i can't bind selecteditems
if have suggestion or sample work, great help
can use 2 observable collections? 1 selected , 1 unselected. seems easiest way implement such functionality.
public class mainviewmodel { private readonly observablecollection<item> _selecteditems = new observablecollection(); private readonly observablecollection<item> _unselecteditems = new observablecollection(); public ienumerable<item> selecteditems { { return _selecteditems; } } public ienumerable<item> unselecteditems { { return _unselecteditems; } } private void unselectitems() { movefromonecollectiontoanother(_unselecteditems, _selecteditems, ...); } private void selectitems() { movefromonecollectiontoanother(_selecteditems, _unselecteditems, ...); } private void movefromonecollectiontoanother(icollection<item> source, icollection<item> destination, ienumerable<item> itemstomove) { foreach (var item in itemstomove) { source.remove(item); destination.add(item); } } }
Comments
Post a Comment