开发者

Disabling Drop on certain items in Silverlight Toolkit's TreeViewDragDropTarget

开发者 https://www.devze.com 2023-01-23 02:06 出处:网络
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.

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

精彩评论

暂无评论...
验证码 换一张
取 消