Basically in the treeview, I have a list of items, if the item is of type "Group", then I can add / drag drop items into it.
How can I achieve that in code? I 开发者_如何学Gotried DragEnter, DragOver events and setting the allowdrop property to false if the target item is not a group object but to no avail. Any advice please?
Cheers
You'll want to set the Effects to None (or turn off Copy/Link/Move more specifically).
A good example of doing this programmatically is within TreeViewDragDropTarget itself, as it contains logic to similarly disable if you're trying to drag an item under itself.
http://silverlight.codeplex.com/SourceControl/changeset/view/56962#779753
The relevant snippet:
if (itemsControl == null || IsTreeViewItemDraggedInDescendent(args) || IsTreeViewItemDraggedDirectlyAboveOrBelowSelf(args))
{
SW.DragDropEffects effects = args.AllowedEffects & (~(SW.DragDropEffects.Copy | SW.DragDropEffects.Link | SW.DragDropEffects.Move));
args.Effects = effects;
if (args.Effects != args.AllowedEffects)
{
args.Handled = true;
}
}
精彩评论