1

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 tried 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

1 Answer 1

2

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;
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.