i looking implementing 2 way drag , drop functionality between listbox , datagrid column in wpf. have searched through net , managed grab drag-drop samples don't fulfill needs, plus of them having missing codes. datagrid contains 2 columns employeename , departmentname. these values coming collection loaded employeename only. means departmentname column blank. user can select appropriate department using drag-drop. department names loaded in listbox. departmentname required selected listbox, draged , droped in datagrid column. employeename mapped department name. once dropped, department name should removed listbox can't mapped against employee. mapping can altered dragging department name listbox datagrid , re-selecting departmentname drag-drop.
my xaml this. (it not employee/department in code have used explain looking for)
<datagrid x:name="datagridemployeemapping" grid.row="1" grid.column="0" grid.columnspan="2" margin="5,5,5,5" itemssource="{binding elementname=mwindow, path=settings.employeemapping}" gridlinesvisibility="vertical" autogeneratecolumns="false" canuseraddrows="false" isreadonly="false" selectionmode="single" > <datagrid.columns> <datagridtextcolumn header="employee name" binding="{binding path=ename}" width="1*" isreadonly="true" /> <datagridtextcolumn header="department name" binding="{binding path=dname}" width="1*" isreadonly="true" /> </datagrid.columns> </datagrid> <listbox x:name="listboxdepartmentdata" grid.column="2" grid.row="1" margin="5,5,5,5" itemssource="{binding elementname=mwindow, path=departmentdetails}" displaymemberpath="name" scrollviewer.verticalscrollbarvisibility="visible"> </listbox>
any link, sample code, suggestion appreciated. regards, minal
i try this:
http://www.codeproject.com/articles/420545/wpf-drag-and-drop-mvvm-using-behavior
you have extend interfaces little bit:
interface idragable { type datatype { get; } // removes department employ if source = grid , if source = listbox removes department list. void remove(object i); // returns department if source = grid , if source = listbox. object getdatatodrag(); } interface idropable { type datatype { get; } // if target = grid -> set department on current employee, if target = listbox -> add item listbox. void drop(object data) }
so need 2 viewmodels -> 1 grid, , 1 listbox , of them implement idragable , idropable.
and behaviors pretty same in codeproject article posted above.
if need further assistance them ask ;)
Comments
Post a Comment