Drag and Drop between two CustomContactList problem


hello i'm building small wpf app want drag , drop items between 2 customcontactlist.

i want when drag contact has moved list , not copied. , code don't permit me this. here sample of screenshot :

//event handler mouse down of listbox. //this start drag drop operation private void mousedownhandler(object sender, mousebuttoneventargs e) { customcontactlist parent = (customcontactlist)sender; //set drag source can //remove item once item dropped on listbox firstlist = parent; //get object source selected item object data = getobjectdatafrompoint(parent, e.getposition(parent)); //if data not null start drag drop operation if (data != null) dragdrop.dodragdrop(parent, data, dragdropeffects.all); } //event handler drop event of listbox private void drophandler(object sender, drageventargs e) { customcontactlist parent = (customcontactlist)sender;

//get data arguments. //we specify typeof string since know our data type object data = e.data.getdata(typeof(string)); //remove object source. collection must implement inotifycollectionchanged //firstlist.removeat(0); //<- here issue there no removeat in lync!! //add new parent (the "destination" listbox) parent.items.add(data); } //gets object element selected (from point) in listbox (source) private static object getobjectdatafrompoint(customcontactlist source, point point) { uielement element = source.inputhittest(point) uielement; var frameworkelement = element frameworkelement; if (frameworkelement != null) { //on récupère dans dc tout le datacontext qui contient les différentes informatioons if (frameworkelement.datacontext != null) { var dc = frameworkelement.datacontext.tostring(); if (parsenuri(dc) != null) { return parsenuri(dc); } } else { return null; } } return null; }

//parse of datacontext have uri" private static object parsenuri (string str) { if (str.indexof("uri") != -1) { char[] delimiterchars = { ':', '}' }; string[] words = str.split(delimiterchars); foreach (string s in words) { if (s.indexof("+") != -1) { return s; } else if (s.indexof("@") != -1) { return s; } else { continue; } } } return null; }


this xaml :

<!-- //////////////////////////////////////////// first contact list //////////////////////////////////////////// -->

<controls:customcontactlist x:name="firstlist" horizontalalignment="left" height="256" margin="5,2.5,0,0" verticalalignment="top" width="390" background="#fff5ffd3" previewmouseleftbuttondown="mousedownhandler" grid.columnspan="4" grid.row="2" /> <!-- //////////////////////////////////////////// second contact list //////////////////////////////////////////// --> <controls:customcontactlist x:name="secondlist" horizontalalignment="center" height="136" margin="7,0,10,10" verticalalignment="bottom" width="492" rendertransformorigin="0.5,0.5" background="#ffe3ffe3" grid.columnspan="3" grid.row="5" allowdrop="true" drop="drophandler" grid.column="2" />


so please see huge mistake in code?  i inspired myself code make drag , drop.

so want delete item wich dragged , dropped first second list , apparently there no removeat working on customcontactlist...

i see i'm not manipulating customcontactlistitem during drag , drop operation maybe it's error. 

and because of can drag same contact first list , dropped thousand of times in other list... , need unique. if can move list resolve problem.

thank lot,

sincerely, ahmed ben salem





Lync Server  ,  Unified Communications  >  Microsoft Lync Client Development



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

Catalog Staging

How to Share webservice object to all user