c# - Determine in code whether to allow a dragdrop drop using the Silverlight Toolkit -
i'm using silverlight toolkit implement drag/drop functionality in silverlight 4 web application. drag source listbox, , i've got eighteen potential drop targets. need allow/disallow dropping based on string value on dragged object.
i have no problem doing comparison , determining whether or not item allowed dropped on target, however, i'm having trouble figuring out best event handle, , how make not accept drop.
i've looked @ dragenter event, , looks best place handle this, i'm not quite sure need make not drop. here's snippet of of code i've tried, doesn't prevent drop:
lbdragdrop.dragenter += (src, e) => { vaultsocketviewmodel vm = this.datacontext vaultsocketviewmodel; listboxdragdroptarget target = src listboxdragdroptarget; observablecollection<itemmodel> listboxbinding = vm.slots[target.name]; object data = e.data.getdata(e.data.getformats()[0]); itemdrageventargs eventargs = data itemdrageventargs; selectioncollection coll = eventargs.data selectioncollection; itemmodel newitem = coll.select(t => t.item).oftype<itemmodel>().firstordefault(); if (!target.name.startswith(newitem.itemslot)) // don't allow drop { e.effects = microsoft.windows.dragdropeffects.none; e.handled = true; } else { } };
just change effects none (like you're doing) should enough - example of internal code in treeview drag drop target in toolkit (the seteffects method)
http://silverlight.codeplex.com/sourcecontrol/changeset/view/57505#779753
Comments
Post a Comment